Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Question

Understand how to best supervise a diverse workforce. P-635

Answered: 1 week ago