Question: Background: In this program, our goal is see the differences between Java and C when it comes to arrays. Prompt FILENAME: MathGame.java I love to

Background:
In this program, our goal is see the differences between Java and C when it comes to arrays.
Prompt
FILENAME: MathGame.java
I love to solve puzzles. Some of my favorite puzzles are the ones you can redo multiple times. Sometimes you just need to shuffle them them up and you will have a unique experience.
I would like you to create a program that does the following:
Ask the user how many numbers they would like to generate. User will put in an integer valued from 2-25. I will call this variable n.
Create n random values and store them in an integer array. These random numbers should be between 5 and 20.
Create a menu that will ask the user if they would like to play game, shuffle, generate new numbers, sort or exit.
If they select play game, display each value in the array and ask the user to add all the values up. If they enter the correct number, print out a success message. If it is incorrect print out a message saying they were wrong and what the correct number is.
If they select shuffle, print the current state of the array and ask the user how many times they would like to shuffle. For each shuffle, randomly select two values and switch their values in the array. Print out the final state of the array.
If they select generate new numbers, reassign all values in the current array. Do not create a new array. (Ranges should be 5-20)
If they select sort array, sort the array ascending (1,2,3).
If they select exit, end the loop. Do not use the quit method.
Create a method that takes in an integer array and prints out the list in a formatted way.
Sample Run:
Welcome to random number generator!
How many values would you like to use:
4
Created!
Select your option:
1. Play Game
2. Swap Values
3. New Values
4. Sort
5. Exit
1
Add these values:
515620
30
That was incorrect. The value adds to be: 46
Select your option:
1. Play Game
2. Swap Values
3. New Values
4. Sort
5. Exit
1
Add these values:
515620
46
That is correct!
Select your option:
1. Play Game
2. Swap Values
3. New Values
4. Sort
5. Exit
2
Current: 515620
How many swaps?
1
Final: 515206
Select your option:
1. Play Game
2. Swap Values
3. New Values
4. Sort
5. Exit
4
Current: 515206
Final: 561520
Select your option:
1. Play Game
2. Swap Values
3. New Values
4. Sort
5. Exit
3
New Values: 181988
Select your option:
1. Play Game
2. Swap Values
3. New Values
4. Sort
5. Exit
5
Goodbye

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 Programming Questions!