Question: Write a program that will prompt the user for their name and a seed to use in your random number generator (so everyone has the
Write a program that will prompt the user for their name and a "seed" to use in your random number generator (so everyone has the same pseudorandom results). Your program will create an array of random numbers and then have the user choose from a menu what operations to do on that array.
example:
Please enter the size of the array: 32 Size must be from 1 - 15. Please reenter: 12
Please enter a seed: 12345
Please enter your name: Joe Bob Allen III
Name: Joe Bob Allen III Seed: 12345
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 1
Array: 4 4 6 0 4 4 7 0 7 6 5 6
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 2
Total: 53
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 3
Largest: 7
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 4
Please enter the integer to count: 6 6 occurred 3 time(s)
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 4
Please enter the integer to count: -1 -1 occurred 0 time(s)
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 1
Array: 4 4 6 0 4 4 7 0 7 6 5 6
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 5
Please enter the index of the integer to change: 0
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 1
Array: 7 4 6 0 4 4 7 0 7 6 5 6
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 5
Please enter the index of the integer to change: 0
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 1
Array: 7 4 6 0 4 4 7 0 7 6 5 6
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 6
Array shifted left
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 1
Array: 4 6 0 4 4 7 0 7 6 5 6 7
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 0
A new array has been generated
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 1
Array: 5 7 2 1 8 0 2 4 1 7 2 3
Please choose an option: 0 Fill the array with new random numbers 1 Print the array 2 Find the total of elements in the array 3 Find the largest element in the array 4 Count how many times an integer occurs in the array 5 Replace one element of the array with a random int 6 Circular shift the array to the left 7 Circular shift the array to the right 8 Exit 8
Your program: should be named MinilabReview.java and will create an array of (pseudo)random ints and present a menu to the user to choose what array manipulations to do. Specifically, the program should: Declare constants to specify the maximum size of the array (15) and the maximum integer that it can contain (8). Ask the user what the size of the array should be. Read in the size; it should be between 1 (inclusive) and the predeclared maximum (inclusive). Keep making the user re-enter the value as long as it is out of bounds. Ask the user to enter a seed for the generation of random numbers (this is so everyones results will be the same, even though random). Ask the user to enter their name. Print the name and seed according to the format shown in the given example. Create a new random number generator using the seed. Create the array and fill it in with random numbers from your random number generator. (Everyones random numbers therefore array elements should be in the range 0 to and everyones random numbers should match). Show the user a menu of options (see example that was given). Implement each option. The output should be in the exact same format as the example. Finally, the menu should repeat until the user chooses the exit option. Example: Please see the example.txt that you are given for a rather long example of running the program. Please note: If you use the same seed as in the example, your results should be the same as the example. Please be sure that the formatting is EXACT, including words, blank lines, spaces, and tabs. Not all of the options nor all of the error checking has been done in the given example, so you will have to add some test cases. There is 1 space after each topic (Array: ) or (Length: ) There are 2 spaces between each element when the array is listed There are tabs before and after each option when the menu is printed Comments and formatting: Please put in an opening comment that briefly describes the purpose of your program. Each constructor/method should have a brief descriptive comment. Also, please be sure that your indenting is correct and that your variable names are meaningful. This is all for Maintainability and will be worth 10% of your program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
