Please, I want it in c++ form and not in a class form. if else statment will be
ID: 3758898 • Letter: P
Question
Please, I want it in c++ form and not in a class form. if else statment will be fine. Please, take a look at the sample runs and understand the question carefully. Answering the question properly is very important for me.
write a program that prompts the user to enter a letter grade A/a,B/b, C/c, D/d, or F/f and displays its corresponding numeric value 4,3,2,1 or 0. Here is a sample run:
Enter a letter grade : B
The numeric value for grade B is 3
Enter a letter grade : b
The numeric value for grade b is 3
Enter a letter grade : T
T is an invalid grade!
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
char input;
do{
cout << "Enter a letter Gragde:" << endl;
cin >> input;
if(input=='A')
{
cout << "The numeric value for grade A is 4"<< endl;
}
else if(input=='a')
cout << "The numeric value for grade a is 4"<< endl;
if(input=='B')
{
cout << "The numeric value for grade B is 3"<< endl;
}
else if(input=='b')
cout << "The numeric value for grade b is 3"<< endl;
if(input=='C')
{
cout << "The numeric value for grade C is 2"<< endl;
}
else if(input=='c')
cout << "The numeric value for grade c is 2"<< endl;
if(input=='D')
{
cout << "The numeric value for grade D is 1"<< endl;
}
else if(input=='d')
cout << "The numeric value for grade d is 1"<< endl;
if(input=='F')
{
cout << "The numeric value for grade F is 0"<< endl;
}
else if(input=='f')
cout << "The numeric value for grade f is 0"<< endl;
}while((input!='A')||(input!='a')||(input!='B')||(input!='b')||(input!='C')||(input!='c')||(input!='D')||(input!='d')||(input!='F')||(input!='f'));
return 0;
}