Write a program that takes as input a class score. Output the grade for the class based on the
following guideline:
ï‚· Exactly 100 is A+
ï‚· 90and above is A
ï‚· 80 and above is B
ï‚· 70 and above is C
ï‚· 60 and above is D
ï‚· Anything less than 60 is F
ï‚· Anything more than 100 or less than 0 is invalid input.
#include <iostream>
using namespace std;
int main(){
int score;
cout<<"Enter score[0-100]: ";
cin>>score;
if (score==100){
cout<<"Grade: A+\n";
}
else if (score >= 90 && score < 100)
{
cout<<"Grade: A\n";
}
else if (score >= 80 && score <= 89)
{
cout<<"Grade: B\n";
}
else if (score >= 70 && score <= 79)
{
cout<<"Grade: C\n";
}
else if (score >= 60 && score <= 69)
{
cout<<"Grade: D\n";
}
else if (score >= 0 && score <= 59)
{
cout<<"Grade: F\n";
}else{
cout<<"Invalid input.\n";
}
system("pause");
return 0;
}
Comments
Leave a comment