vendredi 14 septembre 2018

If/Else Statement Only Outputs One Statement No Matter What

my code is set to be an if/else statement. However, it will not come out properly! No matter what value I put in, only "4.0" will come out. When I put 'A-', it still outputs '4.0' Please help! Code below:

#include <iostream>
using namespace std;

int main()
{
int letGrade;
cout << "Enter the 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";
else if (letGrade = 'B+')
    cout << "The numeric value is 0.0\n";
else
    cout << "That's an invalid numeric value.\n";
return 0;
}

Aucun commentaire:

Enregistrer un commentaire