Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program that will prompt the user to enter the number of classes tha

ID: 3624724 • Letter: W

Question


Write a C++ program that will prompt the user to enter the number of classes that he/she is enrolled in this semester and then prompt the user to enter the grade and number of hours for each class. Finally, the program should calculate and print the grade point average for that student this semester.

A sample run of your program should be designed as follows:


Welcome to the GPA Calculator

How many classes did you take this semester? 5

Hours for class 1? 3
Grade for class 1? A

Hours for class 2? 2
Grade for class 2? B

Hours for class 3? 3
Grade for class 3? C

Hours for class 4? 3
Grade for class 4? A

Hours for class 5? 4
Grade for class 5? D

Your grade point average is 2.67




Program Requirements:
1) Comments to include your name, class, assignment number, point value, etc. Also, use comments to explain the action of your code.
2) Display the grade point average accurate to two decimal places.
3) Use an integer variable for the hours for a class and use a character variable for the grade for a class.
4) Use a count-controlled loop in your program.
5) Use a switch statement on the letter grade. Both upper case and lower case letters are acceptable as letter grades.
6) Format the output precisely as above, including ? and spacing.

Explanation / Answer

please rate - thanks

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{int hours,tothours=0,points,totpoints=0,i,count=0;
char grade;
double gpa;
cout<<"Welcome to the GPA Calculator ";
cout<<"How many classes did you take this semester? ";
cin>>count;
for(i=0;i<count;i++)
   {cout<<" Hours for class "<<i+1<<"? ";
   cin>>hours;
   cout<<"Grade for class "<<i+1<<"? ";
   cin>>grade;
   tothours+=hours;
   switch(grade)
      {case 'a':
       case 'A':points=4;
                break;
       case 'b':        
       case 'B':points=3;
                break;
       case 'c':        
       case 'C':points=2;       
                break;
       case 'd':        
       case 'D':points=1;
                break;
       case 'f':       
       case 'F':points=0;
                break;
     }
   totpoints=totpoints+points*hours;
   }
cout<<" Your grade point average is "<<setprecision(2)<<fixed<<showpoint<<(double)totpoints/tothours<<endl;
system("pause");
return 0;
}


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote