0
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main()
{

    cout << " WELCOME TO GPA CALCULATOR \n\n"<< endl;
    int x, nument;
    float GPA, TotalHrs = 0, GEP = 0, CrHours, X, Y, TotalPts;
    char Grade, A, B, C, D, E, F;
    char choice = 'Y';
    cout << "Enter the amount of course. \n";
    cin >> nument;
    for (int i = 1; i <= nument; i++) {

        cout << "Enter the Grade of the course.  ";
        cin >> Grade;
        switch (Grade)
        {
        case'A':
        case'a':
                GEP = 4;
                break;
        case'B':
        case'b':
                GEP = 3;
                break;
        case'C':
        case'c':
                GEP = 2;
                break;
        case'D':
        case'd':
                GEP = 1;
                break;
        case'F':
        case'f':
                GEP = 0;
                break;
        default:
            cout << "Invalid Input \n";
            break;
        }

        cout << "Enter the credits of the course.  ";
        cin >> CrHours;
        X = ((GEP) * (CrHours));
        TotalPts += X;
        TotalHrs = TotalHrs + CrHours;
        GPA = TotalPts / TotalHrs;
        Y = TotalHrs * 4;
    }
        {
            cout << endl;
            cout << "You want to entry more ? (Y/N) ";
            cin >> choice;
            cout << endl;
        }
        while (choice == 'Y' || choice == 'y') {
            cout << "Enter the Grade of the course.    ";
            cin >> Grade;
            cout << "Enter the credits of the course.  ";
            cin >> CrHours;
            if
                (Grade == 'A' || Grade == 'a')
                GEP = GEP + 4;
            if
                (Grade == 'B' || Grade == 'b')
                GEP = GEP + 3;
            if
                (Grade == 'C' || Grade == 'c')
                GEP = GEP + 2;
            if
                (Grade == 'D' || Grade == 'd')
                GEP = GEP + 1;
            if
                (Grade == 'F' || Grade == 'f')
                GEP = GEP + 0;
            else
            {
                cout << "Invalid entry. Please enter A,B,C,D or F \n";
            }
           X =  GEP + TotalHrs ;
           Y = TotalHrs * 4;

            TotalHrs = TotalHrs + CrHours;
            GPA = TotalPts / TotalHrs;
            {
            cout << endl;
            cout << "You want to entry more ? (Y/N) ";
            cin >> choice;
            cout << endl;
        }
        }
    cout << "Total credits Attempted: \n" << TotalHrs;
    cout << "  " <<endl;
    cout << "Possible obtain points: \n" << Y;
    cout << "  " << endl;
    cout << "Obtained Points " << X ;
    cout << "  " <<endl;
    cout << "Your GPA is: \n" << GPA;
    cout << "  " <<endl;
    {
        cout << "Press X for quit. \n";
        cin >> x;
        cout << endl;
        return (0);
    }
}
2
Contributors
2
Replies
17
Views
3 Months
Discussion Span
Last Post by Eric_19
0

When im trying to get all the grade multiply by the credits of the course to get the points obtained if give me a different value and im trying with different equations and i cant get the right value.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.