converting numbers to letters

hello im trying to do a program that converts numbers to letter for example if the number is betwen 90 to 100 the letter would be 'A' if its 80 to 89 the letter would be 'B' and so on can someone help me please.
You already answered your own question.

1
2
3
4
if (number >= 90 && number <= 100)
{
    letter = 'A';
}
it doesnt show the letter it only change my calculations i did a short program to just start it and it show me as a result 65 not an A can you please check it out thank you.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>

using namespace std;

int main()
{
double midExam, finExam, aveAssign, finGrade;
char A;
char lName[15];
cout <<""<<endl;
cout <<" Please enter student's last name: ";
cin >> lName;
cout <<" Please enter student's midterm exam grade: ";
cin >> midExam;
cout <<" Please enter student's final exam grade: ";
cin >> finExam;
cout <<" Please enter student's average Assignment grade: ";
cin >> aveAssign;

finGrade = 0.35*midExam + 0.3*aveAssign + 0.35*finExam;

if (finGrade>=90 && finGrade <=100)
{
finGrade = 'A';
}
cout <<setw(10)<<lName<<setw(15) <<finGrade<<endl;


system("pause");
return 0;
}
Because finGrade is a double, it will show the ascii number of 'A'

It should be obvious that if you want to display a character to the screen, you need to display a character. In your example, finGrade is not a character, it is a double.
You need to make a new variable.

char finLetterGrade;

then set finLetterGrade to 'A' and then display it instead of finGrade.
got it thanks
Topic archived. No new replies allowed.