Write a program that accepts
student’s numerical grade and converts it into and display it in equivalent
letter grade by using this following info,
87 A 80 to 87 B 70 to 80 C 60 to 70 D Below 60 F }
Algorithm
Step1: Start
Step2: Declare grade
Step3: Input grade
Step4: If grade is greater then and equal
to 87 then grade is A
Step5: If grade is less then 87 and greater
then and equal to 80 then grade is B
Step6: If grade is less then 80 and greater
then and equal to 70 then grade is C
Step7: If grade is less then 70 and greater
then and equal to 60 then grade is D
Step8: If grade is less then 60 then letter
grade is F
Step9: Display grade
Step10: End
#include <iostream>
using namespace std;
int main()
{
int
grade;
cout<<"Please
enter the numerical grade "<<endl;
cin>>grade;
if
(grade>=87)
{
cout<<"You have secured A grade "<<endl;
}
else if
(grade<87 && grade>=80)
{
cout<<"You have secured B grade "<<endl;
}
else if
(grade<80 && grade>=70)
{
cout<<"You have secured C grade "<<endl;
}
else if
(grade<70 && grade>=60)
{
cout<<"You have secured D grade "<<endl;
}
else if
(grade<60)
cout<<"You have failed "<<endl;
}
else
cout<<"Invalid grade "<<endl;
return
0;
}
No comments:
Post a Comment