Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help in Java please!! Display the menu shown below and get the users choice. If the user does not enter a valid choice, output an

Help in Java please!!

Display the menu shown below and get the users choice. If the user does not enter a valid choice, output an appropriate message and prompt for another choice.

Please choose one of the following options for your math quiz:

1. Addition with numbers 1-10

2. Addition with numbers 1-100

3. Subtraction with numbers 1-10

4. Subtraction with numbers 1-100

5. Multiplication with numbers 1-10

6. Exit the program

If the user chooses one of the first five menu options, display five problems of the requested type to the user. For example, if the user chooses option 1, your program should display five addition problems, one at a time, using randomly generated operands between 1 and 10. After each problem, your program should read the users answer and display an appropriate error message: either That is the correct answer! or Sorry, that is incorrect. The correct answer is X, where X is the correct answer to the arithmetic problem. If the user chooses the last menu option, the program should output the number of problems correct, the number of problems tried, and the percentage of problems correct to 2 decimal places before terminating.

Hint: You can use the following formula to generate random numbers:

(int)(lowerBound + Math.random() * (upperBound lowerBound + 1))

You may use literals in place of the upper and lower bounds. For instance, to display values between 1 and 10 (inclusive on both ends), the formula would look like this:

(int)(1 + Math.random() * 10)

-Output example so we can test the Program is shown below-

Please choose one of the following options for your math quiz:

1. Addition with numbers 1-10

2. Addition with numbers 1-100

3. Subtraction with numbers 1-10

4. Subtraction with numbers 1-100

5. Multiplication with numbers 1-10

6. Exit the program

2

Enter the answer to the following problem: 12 + 37

49

That is the correct answer!

Enter the answer to the following problem: 47 + 90

137

That is the correct answer!

Enter the answer to the following problem: 77 + 67

34

Sorry, that is incorrect. The correct answer is 144

Enter the answer to the following problem: 42 + 14

55

Sorry, that is incorrect. The correct answer is 56

Enter the answer to the following problem: 40 + 46

86

That is the correct answer!

Please choose one of the following options for your math quiz:

1. Addition with numbers 1-10

2. Addition with numbers 1-100

3. Subtraction with numbers 1-10

4. Subtraction with numbers 1-100

5. Multiplication with numbers 1-10

6. Exit the program

8

Valid choices are 1-6; please re-enter

7

Valid choices are 1-6; please re-enter

5

Enter the answer to the following problem: 6*3

18

That is the correct answer!

Enter the answer to the following problem: 4*2

8

That is the correct answer!

Enter the answer to the following problem: 8*1

8

That is the correct answer!

Enter the answer to the following problem: 6*6

12

Sorry, that is incorrect. The correct answer is 36

Enter the answer to the following problem: 3*6

18

That is the correct answer!

Please choose one of the following options for your math quiz:

1. Addition with numbers 1-10

2. Addition with numbers 1-100

3. Subtraction with numbers 1-10

4. Subtraction with numbers 1-100

5. Multiplication with numbers 1-10

6. Exit the program

6

You got 12 problems correct out of 15 problems attempted. That is 80.00 percent correct. Goodbye!

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

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions