Answer to Question #289981 in C++ for ali

Question #289981

Write a program that reads a grade, A, B, C, D, or F and then prints “Excellent”, “Good”, “Fair”,” Poor”,” Failure”.


1
Expert's answer
2022-01-26T09:55:19-0500
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	vector<char> vc;
	char c;
	cout<<"Please, enter grades A,B,C,D or F (0 - exit): ";
	do
	{
		cin>>c;
		if(c=='0')break;
		if(c=='A'||c=='B'||c=='C'||c=='D'||c=='F')
			vc.push_back(c);
	}while(true);
	
	vector<char>::iterator it;
	
	for(it=vc.begin();it!=vc.end();++it)
	{
		if(*it=='A')
			cout<<"\nExcellent";
		else if(*it=='B')
			cout<<"\nGood";
		else if(*it=='C')
			cout<<"\nFair";
		else if(*it=='D')
			cout<<"\nPoor";
		else if(*it=='F')
			cout<<"\nFailure";
	}
}

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