Program instructions:
Write a program that would allow a user to enter student names and Final grades (e.g. A,B,C,D,F) from their courses. You do not know how many students need to be entered. You also do not know how many courses each of the students completed. Design your program to calculate the Grade Point Average (GPA) for each student based on each of their final grades. The program should output the Student name along with the GPA.
I have written a program which allows me to have a user input grades and have the program average their total grade. However, I need to make it so that the user is able to input a letter grade (a,b,c,d) and have the program convert each letter to their corresponding values (a=4,b=3,c=2,d=1) and then average their grade according to THOSE numbers so as to accurately calculate their GPA.
#include <iostream>
#include <string>
usingnamespace std;
int main() {
string nameStudent;
double sumGrade = 0;
double grade;
int numGrade;
cout << "Enter name of student" << endl;
cin >> nameStudent;
cout << "Please enter the number of grades" << endl;
cin >> numGrade;
for (int count = 1; count <= numGrade; count++)
{
cout << "PLease input a grade ";
cin >> grade;
sumGrade += grade;
}
double average = sumGrade/numGrade;
cout << nameStudent << " 's average grade is " << average;
return 0;
}
What do I need to add to this code to make these changes? Any help would be greatly appreciated as this assignment is due in 90 minutes! Thanks in advance and hopefully someone reads this before then. ANY HELP WOULD BE VERY MUCH APPRECIATED!
Have the user input a char for a letter grade (A, B, C, D, F) and then use a switch statement to associate the letter grade with an actual grade point.
OK i finally figured it out but now I cant get it to "float" the gpa so i only get whole numbers when i should be gettting fractions. For instance a+b+c+d should average out to 2.5 but i get "2"