Question: Language C++, WITHOUT USING ARRAYS and without adding more variables to calculate the total GPA. Below is the code that needs to be modified. Need

Language C++, WITHOUT USING ARRAYS and without adding more variables to calculate the total GPA. Below is the code that needs to be modified. Need help with "you got a(n)" statements specifically.

#include #include

using namespace std;

int main () { int totalClass; string choice; do {

cout << " How many classes ? " ; cin >> totalClass;

int counter =0; int sumValue = 0; do { char grade; cout << "Enter a grade for class " << counter+1 << ": "; cin >> grade;

if ( grade == 'a' || grade == 'A') sumValue += 4; else if ( grade == 'b' || grade == 'B') sumValue += 3; else if (grade == 'c' || grade == 'C') sumValue +=2; else if (grade == 'd' || grade == 'D') sumValue +=1; else if (grade == 'f' || grade == 'F') sumValue +=0;

counter++; // update the counter

} while (counter < totalClass);

// must fix . CANNOT declare more variables // MUST USE CONCEPTS DISCUSSED IN CLASS double GPA = sumValue/totalClass ; // this will NOT WORK!!

cout.setf (ios::fixed); cout.setf (ios::showpoint); cout.precision (1);

cout << " GPA is " << GPA << endl;

cout << "Again?"; cin >> choice;

}while ( choice == "yes" || choice == "Yes" );

return 0; }

Modify the GPA calculator shown in class so that it now does the following (you MUST use the exact same code as presented in class):

-All other input not a letter grade is considered invalid. If invalid input is detected, the program should display the message "Invalid Input" and keep asking the user to input a grade until a valid one is entered, before proceeding.

-After displaying the GPA, the program should also display a log of the user's grades. You may refer to the sample output below for an example (remember, you CANNOT use any concepts or ideas not yet discussed in class).

-There should also be a sentence describing how well the user did, based on their GPA:

-Students with an A average should see the sentence "You did the best!"

-Students with a B to C average should see the sentence "You did very well!"

-Students with a D to F average should see the sentence "You did alright!"

-You may assume that the player always enters correct input when asked how many classes they took.

-You may also assume that the player always enters correct input when asked if they want to do the calculation again.

Example output:

How many classes? 4

Enter class 1: b

Enter class 2: h

Invalid entry!

Enter class 2: 3

Invalid entry!

Enter class 2: A

Enter class 3: B

Enter class 4: D

GPA: 2.8

You got a(n) b in class 1.

You got a(n) A in class 2.

You got a(n) B in class 3.

You got a(n) D in class 4.

You did very well!

Again? yes

How many classes? 2

Enter class 1: A

Enter class 2: A

GPA: 4.0

You got a(n) A in class 1.

You got a(n) A in class 2.

You did the best!

Again? Yes

How many classes? 2

Enter class 1: D

Enter class 2: F

GPA: 0.5

You got a(n) D in class 1.

You got a(n) F in class 2.

You did alright!

Again? No

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!