I have an assignment where we have to present letter grades. The data types without the plus or minus will not put out the correct value. Value 'A' outputs correctly but 'A-' does not. The code is below:
#include <iostream>
using namespace std;
int main()
{
char letGrade;
cout << "What is your letter grade? ";
cin >> letGrade;
if (letGrade == 'A')
cout << "The numeric value is 4.0\n";
else if (letGrade == 'A-')
cout << "The numeric value is 3.5\n";
cout << "That's an invalid numeric value.\n";
return 0;
}
Aucun commentaire:
Enregistrer un commentaire