In: Computer Science
(c++ programming) We want to assign a letter grade based on the following scaling chart. Write a program to do it Enter your score: 85 Your grade is a “B” 0-------------------60---------70-------------80-----------90-------------100 F D C B A MUST use nested if-else statements.
C++ Code
#include <iostream>
using namespace std;
int main()
{
float score;
cout<<"Enter your Score : ";
cin>>score; // input the score
if(score>=100 && score<=90) //checking the score is
between 100 and 90
{
cout<<"Your grade is A";
}
else if(score>=80 && score<90) //checking the score
is between 80 and 90
{
cout<<"Your grade is B";
}
else if(score>=70 && score<80) //checking the score
is between 70 and 80
{
cout<<"Your grade is C";
}
else if(score>=60 && score<70) //checking the score
is between 60 and 70
{
cout<<"Your grade is D";
}
else
{
cout<<"Your grade is F"; // display if score is less than
60
}
return 0;
}
Output