Write a C++ program that calculates and displays astudent’s grade-point average
ID: 3616946 • Letter: W
Question
Write a C++ program that calculates and displays astudent’s grade-point average (GPA) after taking threecourses. The program reads a three-lined text data file, each linecontaining a course ID (a string without whitespace), the number ofcredit hours for the course (an integer), and the grade for thecourse (an upper- or lowercase character).
A GPA is calculated by dividing the total amount of grade-pointsby the total number of credit hours. “Grade-points” fora course is the number of credit hours multiplied by a numericvalue based on the letter grade: 4 for an ‘A,’ 3 for a‘B,’ 2 for a ‘C,’ 1 for a ‘D,’and 0 for an ‘F.’
For example, suppose a student earned the following:
Course ID Hours Grade
CISS241 4 ‘A’
MTH200 3 ‘B’
HST105 3 ‘C’
Then, total credit hours is 4 + 3 + 3 = 10, and the total amountof grade-points is 4 * 4 (A) + 3 * 3 (B) + 3 * 2 (C) = 16 + 9 + 6 =31.
Therefore, GPA = total grade points / total credit hours = 31 /10 = 3.1.
You can make up your own data file using Notepad. To make itconvenient for me to run and evaluate your program, name your inputfile CISS241_Makeup.dat.
Your program should display in a nice and pretty tabularform all input data along with the calculated grade-points for eachcourse and, of course, the calculated GPA.
Explanation / Answer
please rate - thanks #include #include using namespace std; main() { int i,credits,totalcredits=0; double add,value=0,GPA; string course; char grade; ifstream input; input.open("CISS241_Makeup.dat"); //open file if(input.fail()) //is it ok? { cout>grade; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.