Answer to Question #256691 in C++ for Dion Martins

Question #256691

Write an application that ask the user for a letter grade A, B, C, D, E, or Q to quit. When the user types the user Q the program must end. Display the following using the information on the table below. Use a switch statement for the selection. When the loop terminates display how many A, B, C, D, or E were entered.


Grade Message

A Excellent

B Very Good

C Good

D Fair

E Poor


1
Expert's answer
2021-10-30T23:56:05-0400


#include <iostream>


using namespace std;


int main()
{
    cout<<"\nEnter grades (A,B,C,D,E) or Q to quit:\n";
    char c;
    int count_A=0;
    int count_B=0;
    int count_C=0;
    int count_D=0;
    int count_E=0;
    while(true){
        cin>>c;
        if(c=='Q')
            break;
        switch(c){
            case 'A':
                cout<<"\nExcellent\n";
                count_A++;
                break;
            case 'B':
                cout<<"\nVery Good\n";
                count_B++;
                break;
            case 'C':
                cout<<"\nGood\n";
                count_C++;
                break;
            case 'D':
                cout<<"\nFair\n";
                count_D++;
                break;
            case 'E':
                cout<<"\nPoor\n";
                count_E++;
                break;
        }
    }
    cout<<"\nA was entered "<<count_A<<" times";
    cout<<"\nB was entered "<<count_B<<" times";
    cout<<"\nC was entered "<<count_C<<" times";
    cout<<"\nD was entered "<<count_D<<" times";
    cout<<"\nE was entered "<<count_E<<" times";
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS