Question: Implement a complete program that uses a switch statement In C + + . Demonstrate how to use the keyword break effectively, you should have

Implement a complete program that uses a switch statement In C++. Demonstrate 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.
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'.
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')
please show the sample run of
SAMPLE RUN 1:
Please enter the score: 8
B
SAMPLE RUN 2:
Please enter the score: 7
C
SAMPLE RUN 3:
Please enter the score: -5
Invalid score.
SAMPLE RUN 4:
Please enter the score: 10
A
SAMPLE RUN 5:
Please enter the score: 5
D
SAMPLE RUN 6:
Please enter the score: 4
F
*PLEASE DO THIS IN C++ AND ONLY USE 5 USES OF BREAK AND 1 USE OF DEFAULT IN THIS CODE* Thats it! Thank you.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!