Design a GPA calculator in which the student is allowed to enter maximum of 5 courses along with the course grade. The program should output the final GPA based on the scale below.
90-100 Excellent A 4.00
87-89 Very Good A- 3.75
84-86 Good B+
3.35 80-83 B 3.00
77-79 B- 2.75 74-76
Satisfactory C+ 2.50 70-73 Average C 2.00 67-69 Below Average
C- 1.75 64-66 Poor
D+ 1.50 60-63 D 1.00
<60 Fail F 0.00
#include <iostream>
using namespace std;
int main(){
cout<<"How many courses do you want to enter? ";
int n;
float marks = 0, average = 0, gpa = 0;
string grade;
cin>>n;
for(int i = 0; i < n; i++){
cout<<"Enter course "<<i + 1<<" grade: \n";
cin>>grade;
if(grade == "A") gpa += 4.00;
else if(grade == "A-") gpa += 3.75;
else if(grade == "B+") gpa += 3.35;
else if(grade == "B") gpa += 3.00;
else if(grade == "B-") gpa += 2.75;
else if(grade == "C+") gpa += 2.50;
else if(grade == "C") gpa += 2.00;
else if(grade == "C-") gpa += 1.75;
else if(grade == "D+") gpa += 1.50;
else if(grade == "D") gpa += 1.00;
else gpa += 0;
}
gpa /= n;
cout<<"Final gpa is "<<gpa;
return 0;
}
Comments
Leave a comment