GPA = total grade points / the total credit hours
In this assignment, you need to write a C++ program which can input a student’s courses data, such as how many courses taking, what are the credit hours and grade for each course, then calculate and output the GPA for this student. In your program, you need to construct a loop that runs N times where N is the number of courses that student takes. You also need to write codes to convert a grade to its corresponding grade points using condition branches (if-else-if or case-switch).
For example, a student takes 3 courses in the current semester and receives grades as shown in the following:
Courses |Cred. HRs.| Grade |
Course1 | 4 | B |
Course2 | 4 | C |
Course3 | 3 | A |
For the example student's GPA, the total credit hours are 11, and the grade points are converted by the rule:
A = 4.00 grade points
B = 3.00 grade points
C = 2.00 grade points
D = 1.00 grade points
F = 0.00 grade points
So, the total grade points for the student are 12 + 8 + 12 = 32.
Therefore, the GPA for the student in this semester is:
32/11 = 2.91
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
using namespace std;
int main() {
//
int N;
char g,c,gpa,cr;
//
cout << "How many courses are you taking?: ";
cin>> c;
cout << "Credits for each course: ";
cin>> cr;
cout << "Grades for each course: ";
cin>> g;
//
}
|
Literally all I got, this one assignment has really confused me. please help me step by step to the final product.