dimanche 5 décembre 2021

How can I display the computed average entered by the user and convert it into its equivalent GPA and equivalent verbal interpretation using c++?

This is my draft code. I need to compute for the average of the user. The written exam is consist of 40 items while the practical exam is consist of 60 items with a total of 100. Then, I need to display the average, its equivalent GPA and its verbal interpretation and determine if the student passed or failed using the GPA. My problem is that, in order to determine whether the user passed or failed, I need to use the corresponding GPA. But I don't know how I'm going to do it since the user input is on average and not on GPA format. So I'm asking whether it is possible that I can covert the average into the equivalent GPA or make it so that the average and GPA would be correlated so that I can use it to determine whether the user passed or failed.

#include <iostream>

using namespace std;

int main()
{
    float average, w_average, p_average, GPA, w_mathematics, w_science, w_english, w_filipino, 
    w_MAPEH, p_mathematics, p_science, p_english, p_filipino, p_MAPEH;
    int student_num;
    string fname;
    string mname;
    string lname;

    cout << "Enter your first name: ";
    getline(cin, fname);
    cout << "Enter your middle name: ";
    cin >> mname;
    cin.ignore();
    cout << "Enter your last name: ";
    getline(cin, lname);

    cout << "Enter your student number: ";
    cin >> student_num;

    cout << "Enter your written exam grade in Mathematics : ";
    cin >> w_mathematics;
    cout << "Enter your written exam grade in Science : ";
    cin >> w_science;
    cout << "Enter your written exam grade in English : ";
    cin >> w_english ;
    cout << "Enter your written exam grade in Filipino : ";
    cin >> w_filipino;
    cout << "Enter your written exam grade in in MAPEH : ";
    cin >> w_MAPEH;


    cout << "Enter your practical exam grade in Mathematics : ";
    cin >> p_mathematics;
    cout << "Enter your practical exam grade in Science : ";
    cin >> p_science;
    cout << "Enter your practical exam grade in English : ";
    cin >> p_english ;
    cout << "Enter your practical exam grade in Filipino : ";
    cin >> p_filipino;
    cout << "Enter your practical exam grade in in MAPEH : ";
    cin >> p_MAPEH;


    w_average = (w_mathematics + w_science + w_english + w_filipino + w_MAPEH) /5;
    p_average = (p_mathematics + p_science + p_english + p_filipino + p_MAPEH) /5;
    average = w_average + p_average;
    cout << "Name : "<< fname <<" "<< mname <<" "<< lname <<endl;
    cout << "Student Number : " << student_num << endl;
    cout << "Your average grade is : " << average << endl;

    if (average >= 95.50 && average <= 100)
    cout <<"Your GPA is 1.00" << endl;

    else if (average >= 91.50 && average <= 95.49)
    cout <<"Your GPA is 1.25" << endl;

    else if (average >= 85.50 && average <= 91.49)
    cout <<"Your GPA is 1.50" << endl;

    else if (average >= 81.50 && average <= 85.49)
    cout <<"Your GPA is 1.75" << endl;

    else if (average >= 75.50 && average <= 81.49)
    cout <<"Your GPA is 2.00" << endl;

    else if (average >= 71.50 && average <= 74.49)
    cout <<"Your GPA is 2.25" << endl;

    else if (average >= 65.50 && average <= 71.49)
    cout <<"Your GPA is 2.50" << endl;

    else if (average >= 61.50 && average <= 64.49)
    cout <<"Your GPA is 2.75" << endl;

    else if (average >= 55 && average <= 55)
    cout <<"Your GPA is 3.00" << endl;


    if (average <= 3.0){
    cout << "You passed" << endl;
    }
    else {
    cout << "You failed" << endl;
    }


    if (average >= 95.50 && average <= 100)
    cout <<"Excellent" << endl;

    else if (average >= 91.50 && average <= 95.49)
    cout <<"Very Satisfactory" << endl;

    else if (average >= 85.50 && average <= 91.49)
    cout <<"Very Satisfactory" << endl;

    else if (average >= 81.50 && average <= 85.49)
    cout <<"Satisfactory" << endl;

    else if (average >= 75.50 && average <= 81.49)
    cout <<"Satisfactory" << endl;

    else if (average >= 71.50 && average <= 74.49)
    cout <<"Satisfactory" << endl;

    else if (average >= 65.50 && average <= 71.49)
    cout <<"Needs Improvement" << endl;

    else if (average >= 61.50 && average <= 64.49)
    cout <<"Needs Improvement" << endl;

    else if (average >= 55 && average <= 55)
    cout <<"Highly Needs Improvement" << endl;


    return 0;
}

Aucun commentaire:

Enregistrer un commentaire