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

C++ Imagine that you are a student about to graduate. You realize that it would

ID: 3747802 • Letter: C

Question

C++

Imagine that you are a student about to graduate. You realize that it would be handy to have a tool to help you calculate your GPA and determine whether you are graduating with honors. In the GPA scale, an A is a 4.0, a B is 3.0, a C is 2.0, a D is 1.0, and an F is 0.0. GPA scales typically factor in course credits as well, but all of your classes are the same number of credits, so you can ignore that as a variable. Honor level is based on the following scale: greater than or equal to 3.9 is summacumlaude, 3.8 to 3.89 is magnacumlaude, 3.65 to 3.79 is cumlaude, below 3.65 there are no honors given. Your graduation calculator should prompt the user to input four grades as the numerical value (you can ask four times, one at a time), calculate the average of the inputted grades, display this value to the user, and display a Boolean (true or false) statement for each of the honor levels.

You can use the grades A, A, B, and A as a test case, which should result in the following: Your GPA is 3.75. Graduating summacumlaude is false. Graduating magnacumlaude is false. Graduating cumlaude is true. Graduating without honors is false.

Explanation / Answer

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts. Thanks

//Code

#include<iostream>

using namespace std;

int main(){

              //defining variables needed

              double total=0,avg=0;

              char inputGrade;

              int counter=1;

              //looping until 4 valid grades are received

              while(counter<=4){

                             cout<<"Enter grade "<<counter<<" (A/B/C/D/F): ";

                             //getting grade

                             cin>>inputGrade;

                             //adding to the total based on grade letter

                             if(inputGrade=='A'){

                                           total+=4.0;

                                           counter++;

                             }else if(inputGrade=='B'){

                                           total+=3.0;

                                           counter++;

                             }else if(inputGrade=='C'){

                                           total+=2.0;

                                           counter++;

                             }else if(inputGrade=='D'){

                                           total+=1.0;

                                           counter++;

                             }else if(inputGrade!='F'){

                                           //not a valid grade, will prompt again

                                           cout<<"Invalid grade, try again!"<<endl;

                             }

              }

              //finding the average

              avg=total/4.0;

              //displaying it

              cout<<"Average: "<<avg<<endl;

             

              //finding the honor level and displaying it

              cout<<"Graduating summacumlaude is ";

              if(avg>=3.9){

                             cout<<"true"<<endl;

              }else{

                             cout<<"false"<<endl;

              }

              cout<<"Graduating magnacumlaude is ";

              if(avg>=3.8 && avg<=3.89){

                             cout<<"true"<<endl;

              }else{

                             cout<<"false"<<endl;

              }

             

              cout<<"Graduating cumlaude is ";

              if(avg>=3.65 && avg<=3.79){

                             cout<<"true"<<endl;

              }else{

                             cout<<"false"<<endl;

              }

             

              cout<<"Graduating without honors is ";

              if(avg<3.65){

                             cout<<"true"<<endl;

              }else{

                             cout<<"false"<<endl;

              }

}

/*OUTPUT*/

Enter grade 1 (A/B/C/D/F): A

Enter grade 2 (A/B/C/D/F): A

Enter grade 3 (A/B/C/D/F): B

Enter grade 4 (A/B/C/D/F): A

Average: 3.75

Graduating summacumlaude is false

Graduating magnacumlaude is false

Graduating cumlaude is true

Graduating without honors is false