Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is Java Programming. This assignment tries to ensure that the students know the if-else statement and switch statement. Objectives: 1. The structures of if-else

This is Java Programming.

This assignment tries to ensure that the students know the if-else statement and switch statement.

Objectives:

1. The structures of if-else branching

2. The structures of switch branching

3. Know that all switch branching can be covert to if-else branching

QUESTION:

Write a game program. The computer will ask the user to input a score. The program will first check if the score is valid (between 0 and 100, inclusive). If the score is not valid, print out the error message and exit the program. Otherwise, display the corresponding letter grade.

REQUIREMENTS:

1. You need first use if statement to decide whether the input is valid. If not, print out the error message and exit the program.

2. You need use if-else structure to display the letter grade.

3. Comment away the code (do NOT delete it) and rewrite it by using switch structure (please notice that in general, you may not be able to rewrite an if-else statement to switch statement. However, in this particular case, there is a trick to do so easily)

4. In this program, we dont validate users input. We assume that user will enter a score between 0 and 100 inclusive. After we study loop, we can validate the input. As long as the users input is out of the legal range, the program will keep to prompt the user to enter a legal score

Sample Runs: The user input is in Bold and Italic

Sample Run One:

Enter your score (0 -- 100): 86

Your grade is: B

Sample Run Two:

Enter your score (0 -- 100): 91

Your grade is: A

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

Explain the chemical properties of acids with examples.

Answered: 1 week ago

Question

Write the properties of Group theory.

Answered: 1 week ago

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago