Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

-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

  1. -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.
  2. -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).
  3. -There should also be a sentence describing how well the user did, based on their GPA:

Must use string concatenation to display log of the users grade. Can't use array.

#include

using namespace std;

int main() {

string choice;

do {

int classes;

cout << "How many classes did you take? ";

cin >> classes;

char letter;

int total = 0;

int counter = 0;

do {

cout << "Enter Class " << counter+1 << ": ";

cin >> letter;

if(letter == 'a' || letter == 'A') {

total += 4;

}

else if(letter == 'b' || letter == 'B') {

total +=3;

}

else if (letter == 'c' || letter == 'C') {

total +=2;

}

else if (letter == 'd' || letter == 'D') {

total +=1;

}

else if (letter == 'f' || letter == 'F') {

total +=0;

}

else {

cout << "Invalid Entery! " << endl;

cout << "Enter a valid grade. ";

cin >> letter;

}

counter ++;

} while (counter < classes);

double gpa = 1.0*total/classes;

cout << "GPA: " << gpa << endl;

int classesNum = 0;

do {

string gradeLog;

gradeLog = "You got a(n) " + to_string(letter);

gradeLog = gradeLog + " in class ";

gradeLog = gradeLog + to_string(classesNum+1) + ".";

cout << gradeLog << endl;

classesNum++;

} while(classesNum < counter);

if ((gpa > 3.49) && (gpa < 4.00)) {

cout << "You did the best!";

}

else if(gpa > 1.49 && (gpa < 3.48)) {

cout << "You did very well!";

}

else if(gpa > 0.0 && (gpa < 1.48)) {

cout << "You did alright!";

}

cout << " Again? ";

cin >> choice;

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

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago