Question: JAVA- Declare constants to specify the maximum integer that the array can contain (set to 8) and the integer whose occurrences will be counted (set

JAVA- Declare constants to specify the maximum integer that the array can contain (set to 8) and the integer whose occurrences will be counted (set to 3, to be used in one of the menu options).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 what the size of the array should be.Read in the size; it should be greater than 1.Keep making the user re-enter the value as long as it is out of bounds.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 examples that are 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 enter a seed: 1

Please enter the size of the array: 1

Array size must be greater than 1. Please reenter: 0

Array size must be greater than 1. Please reenter: -1

Array size must be greater than 1. Please reenter: 12

Please choose an option: 1 Print the array 2 Find the average 3 Find the largest element 4 Count how many times 3 occurred 5 Count how many elements are less than half of the first element 6 Find how many times numbers repeat consecutively 7 Swap the first and last elements 8 Exit 1

Array: 6 1 1 6 8 4 5 1 1 1 7 7

Please choose an option: 1 Print the array 2 Find the average 3 Find the largest element 4 Count how many times 3 occurred 5 Count how many elements are less than half of the first element 6 Find how many times numbers repeat consecutively 7 Swap the first and last elements 8 Exit 2

Average: 4.0

Please choose an option: 1 Print the array 2 Find the average 3 Find the largest element 4 Count how many times 3 occurred 5 Count how many elements are less than half of the first element 6 Find how many times numbers repeat consecutively 7 Swap the first and last elements 8 Exit 3

Largest: 8

Please choose an option: 1 Print the array 2 Find the average 3 Find the largest element 4 Count how many times 3 occurred 5 Count how many elements are less than half of the first element 6 Find how many times numbers repeat consecutively 7 Swap the first and last elements 8 Exit 4

3Count: 0

Please choose an option: 1 Print the array 2 Find the average 3 Find the largest element 4 Count how many times 3 occurred 5 Count how many elements are less than half of the first element 6 Find how many times numbers repeat consecutively 7 Swap the first and last elements 8 Exit 5

Less than half of first: 5

Please choose an option: 1 Print the array 2 Find the average 3 Find the largest element 4 Count how many times 3 occurred 5 Count how many elements are less than half of the first element 6 Find how many times numbers repeat consecutively 7 Swap the first and last elements 8 Exit 6

Repeats: 4

Please choose an option: 1 Print the array 2 Find the average 3 Find the largest element 4 Count how many times 3 occurred 5 Count how many elements are less than half of the first element 6 Find how many times numbers repeat consecutively 7 Swap the first and last elements 8 Exit 7

Please choose an option: 1 Print the array 2 Find the average 3 Find the largest element 4 Count how many times 3 occurred 5 Count how many elements are less than half of the first element 6 Find how many times numbers repeat consecutively 7 Swap the first and last elements 8 Exit 1

Array: 7 1 1 6 8 4 5 1 1 1 7 6

Please choose an option: 1 Print the array 2 Find the average 3 Find the largest element 4 Count how many times 3 occurred 5 Count how many elements are less than half of the first element 6 Find how many times numbers repeat consecutively 7 Swap the first and last elements 8 Exit 9

Illegal option, try again

Please choose an option: 1 Print the array 2 Find the average 3 Find the largest element 4 Count how many times 3 occurred 5 Count how many elements are less than half of the first element 6 Find how many times numbers repeat consecutively 7 Swap the first and last elements 8 Exit 8

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