Write a program that reads a grade, A, B, C, D, or F and then prints “Excellent”, “Good”, “Fair”,” Poor”,” Failure”.
#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";
}
}
Comments
Leave a comment