C++ Assignment (Please post the solution and output) /* Please submit this progr
ID: 3587478 • Letter: C
Question
C++ Assignment (Please post the solution and output)
/* Please submit this program in pseudocode */
Requires: Variables, data types, and numerical operators, basic input/output, logic (if statements, switch statements)
Write a program that permits the user to enter the grade scored in a programming class (0-100). If the student scored a 100 then alert the user that they got an impeccable score.
1) Modify the program so that if the user scored a 90-100 it informs the user that they scored an A
2) Modify the program so that it will notify the user of their letter grade 0-59 F, 60-69 D, 70-79 C, 80-89 B, 90-100 A
Explanation / Answer
program:--
#include<iostream>
using namespace std;
int main()
{
cout<<"enter grade score of a student :";
int score;
cin>>score; //read score from user
if(score==100) //check if score is 100
cout<<"Impeccable score"<<endl;
else
{
int ch=score/10; //calculation for grade points
cout<<"the grade is :";
switch(ch)
{
case 6:cout<<"D"<<endl; //if grade point is 6 (60-69)
break;
case 7:cout<<"C"<<endl; //if grade point is 7 (70-79)
break;
case 8:cout<<"B"<<endl; //if grade point is 8 (80-89)
break;
case 9:cout<<"A"<<endl; //if grade point is 6 (90-99)
break;
default:cout<<"F"<<endl; //if grade point is less than 6 (0-59)
break;
}
}
return 0;
}
output:--
enter grade score of a student :78
the grade is :C
Process exited normally.
Press any key to continue . . .
enter grade score of a student :44
the grade is :F
Process exited normally.
Press any key to continue . . .
enter grade score of a student :100
Impeccable score
Process exited normally.
Press any key to continue . . .
pseudocode:-
1.main()
2.{
3. read score from user;
4. if score=100 then say impiccable score
5. else
6. {
7. ch=score/10;
8. switch(ch)
9. {
10. case 6: print D;
11. case 7: print C;
12. case 8: print B;
13. case 9: print A;
14. default: print F;
15. }end switch
16. }end if
15.}end main
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.