Answer to Question #259044 in C++ for chelsea

Question #259044

 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.


1
Expert's answer
2021-10-30T10:36:47-0400
#include <iostream>

using namespace std;

int main()
{
	cout << "Please, enter symbols A,B,C,D,E for counting and 'Q' to quit\n";
	int countA = 0;
	int countB = 0;
	int countC = 0;
	int countD = 0;
	int countE = 0;
	char c;
	while(cin>>c&&c!='Q')
	{
		switch (c)
		{
			case 'A':
				countA++;
				break;
			case 'B':
				countB++;
				break;
			case 'C':
				countC++;
				break;
			case 'D':
				countD++;
				break;
			case 'E':
				countE++;
				break;
		}
	}
	cout << "\nYou entered:\nA: " << countA
		<< "\nB: " << countB << "\nC: " << countC
		<< "\nD: " << countD << "\nE: " << countE;
}

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