### Calculate GPA in C++

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:

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:

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

 ``1234567891011121314151617181920`` `````` #include 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.
Last edited on
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859`` ``````// 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 #include ... int main() { /* ASSIGNMENT: a C++ program which can input ... how many courses taking */ std::cout << "How many courses have you attended? "; int howmany; std::cin >> howmany; /* ASSIGNMENT: In your program, you need to construct a loop that runs N times where N is the number of courses that student takes. */ int tot_g_p {}, // total grade points tot_h {}; // total credit hours for(/* iterates as many times as courses attended */) { /* ASSIGNMENT: a C++ program which can input ... what are the credit hours and grade for each course */ std::cout << "\nWhat are the credit hours ... int ... std::cin ... tot_h ... // increment by the hours of this course std::cout << "What is ... char ... std::cin >> ... /* ASSIGNMENT: write codes to convert a grade to its corresponding grade points using condition branches (if-else-if or case-switch) */ switch(/* ??? */) { case 'A': tot_g_p // increment by the proper grade points case ... ... } } std::cout << "Your current GPA is " << // perform a **floating point** division << '\n'; }``````