Answer to Question #317799 in C++ for her

Question #317799

Write a program to ask the user to input a value responding a score on a test. The value should be between 0 and 100 inclusive. Using the IF control structure to output a message containing the letter grade corresponding to the score using the following table.


Score                                    Letter grade

0-40                                      F

41-55                                    D

56-70                                    C

71-85                                    B

86-100                                  A


1
Expert's answer
2022-03-25T04:36:59-0400
#include <iostream>
using namespace std;


int main() {
    int score;


    cout << "Enter a test score: ";
    cin >> score;


    if (score > 100) {
        cout << "The score should be less or equal 100" << endl;
    }
    else if (score > 85) {
        cout << "Your grade is A" << endl;
    }
    else if (score > 70) {
        cout << "Your grade is B" << endl;
    }
    else if (score > 55) {
        cout << "Your grade is C" << endl;
    }
    else if (score > 40) {
        cout << "Your grade is D" << endl;
    }
    else if (score >= 0) {
        cout << "Your grade is F" << endl;
    }
    else  {
        cout << "The score should be great or equal 0" << endl;
    }


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog