Write a C++ program to calculate a students GPA for the semester. The program should accept a student’s name, ID number and the number of courses he/she is taking, then for each course the following data is needed
• the course number a string e.g. BU 101
• course credits “an integer”
• grade received for the course “a character”.
The program should display the student’s name, ID number, the total number of credits for the semester, and grade point average for the semester. A warning message should be also printed if the GPA is less than 2.0 and a congratulatory message if the GPA is 3.0 or above.
Requirements:
• Input student’s name, ID number, course number, number of credits for the course and grade using proper prompts.
• Use a loop to repeat for multiple students until ‘N’ or ‘n’ is entered in response to a prompt.
• Add comments to identify the variables used.
• Create constants representing the points for each grade.
A 4 points
B 3 points
C 2 points
D 1 points
F 0 points
• Calculate using the constants you defined, and whatever data the user enters.
• Use at least 4 functions.
• Include data validation for all data entered
ID Range 0-9999
Number of courses 0 – 5
Grades are A,B,C,D,F.
• Have your program print proper titles for the output.
• Output the report as specified above.
• Comment thoroughly.
(I'm stuck on the bold part of the question about loop terminating with 'N' or 'n'.
int main()
{
string name,coursenum;
int id,numofcourse,credits;
getdata(name,id);
coursedata(numofcourse,coursenum,credits);
return 0;
}
void getdata(string name, int id)
{
cout<<"\tSTUDENT'S GPA CALCULATOR FOR THE SEMESTER\n";
cout<<"_______________________________________________________\n\n";
cout<<"****Please, Enter the required information****\n\n";
cout<<"Enter Student's Name: "; getline(cin,name);
cout<<"Enter ID number in the range 0 - 9999:";cin>>id;
while ((id<0)||(id>9999))
{
cout<<"ERROR :Enter a number in the range 0 - 9999: ";
cin>>id;
}
}
void coursedata(int numofcourse, string coursenum, int credits)
{
const char A = '4',
B = '3',
C = '2',
D = '1',
F = '0';
cout<<"Enter the Number of course students took for the semester\n";
cout<<"(Enter the number of course in the range 0 - 5):"; cin>>numofcourse;
while((numofcourse<0)||(numofcourse>5))
{
cout<<"ERROR :Enter the number of course in the range 0 - 5:";
cin>>numofcourse;
}
cout<<numofcourse<<endl;