Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a complete program that uses a switch statement in C + + . Prompt the user for the score ( assumed to be an

Implement a complete program that uses a switch statement in C++.
Prompt the user for the score (assumed to be an integer between 0 and 10 inclusive).
Read the user input into a variable score of type int.
Also declare a variable called grade of type char.
Assign one of the values 'A','B','C','D,'F' or 'X' to grade based on the value of score.
If score is 0,1,2,3 or 4 the grade is 'F'
If the score is less than 5 or 6 the grade is ''D'.
If the score is 7 the grade is 'C'.
If the score is 8 the grade is 'B'.
If the score is 9 or 10, the grade is 'A'.
If the score is any other value the grade is 'X'.
IMPORTANT: To demonstrate that you know how to use the keyword break effectively, you should have combine cases where appropriate by having only five uses of break in your code and one use of default.
After the switch statement, output the users grade e.g.
Your grade is 'A'.
Or
Invalid score.
(That's for that case where grade has the value 'X')
Below are sample outputs from six separate runs of the program to illustrate. Your output should be identical given the same inputs.
Do not use a loop.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions