Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions

Question

Differentiate the function. r(z) = 2-8 - 21/2 r'(z) =

Answered: 1 week ago

Question

Question What are the advantages of a written bonus plan?

Answered: 1 week ago