Tuesday, December 04, 2012

GPA calculate in C++


// it is use in kust i calculate my gpa that is correct
#include <iostream>
using namespace std;

int main(){
    float nmbr, grade, credits, GPA = 0, totalCredits = 0;

    cout << "Enter The Number of Courses: ";
    cin >> nmbr;

    for(int i = 0; i < nmbr; i++){
        cout << "Enter the credit number for course No. " << i+1 << " : ";
        cin >> credits;
        totalCredits =totalCredits + credits;

        cout << "Enter the grade for course No. " << i+1 << " : ";
        cin >> grade;
         GPA =GPA+grade*credits;
    }

    GPA /= totalCredits;

    cout << "The GPA Is: " << GPA << " / ";
    if(GPA >=.7 && GPA <= 1)
        cout << "F oh no";
    else if(GPA >= 1 && GPA <= 1.33)
        cout << "D";
    else if(GPA >= 1.33 && GPA <= 1.7)
        cout << "D+";
    else if(GPA >=1.7 && GPA <= 2)
        cout << "C-";
    else if(GPA >= 2 && GPA <= 2.33)
        cout << "C";
    else if(GPA >= 2.33 && GPA <= 2.63)
        cout << "C+";
    else if(GPA >= 2.63  && GPA <= 3)
        cout << "B-";
    else if(GPA >= 3 && GPA <= 3.33)
        cout << "B";
    else if(GPA >=3.33 && GPA <= 3.63)
        cout << "B+";
    else if(GPA >=3.63 && GPA <= 4)
        cout << "A-";
    else if(GPA == 4)
        cout << "A oh....................\n";
 

    return 0;
}

No comments:

Post a Comment