write a program that prompts for and accepts input of test ggrades that are inte
ID: 3552170 • Letter: W
Question
write a program that prompts for and accepts input of test ggrades that are integers between 0 and 100. For each numerical test grade, your program should display a corresponding letter grade based on the following rules
if the grade is between 90 and 100 inclusive, display an 'A'.
if the grade is between 80 and 89 inclusive, display a 'B'.
if the grade is between 65 and 79 inclusive, display a 'C'.
if the grade is between 50 and 64 inclusive, display a 'D'.
if the grade is less than 50, display an 'F'.
The program should continue to read and classify the test grades until the user enters -1 as a sentinel value.
Explanation / Answer
#include<iostream>
using namespace std;
int main(){
int x;
cout<<"Please input your grade";
cin>>x;
if(x?90 && x?100) {
cout<<"A";
}
if(x?80 && x?89) {
cout<<"B";
}
if(x?65 && x?79) {
cout<<"C";
}
if(x?50 && x?64) {
cout<<"D";
}
if(x<50) {
cout<<"E";
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.