Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java please Create an array of (pseudo) random ints and present a menu to the user to choose what array manipulations to do. Specifically,

in java please

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 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 you get the same results even though it is 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. ( random numbers therefore array elements should be in the range 0 to and 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.

examples

image text in transcribed

Please enter a seed: 1 Please enter the size of the array: 1 Array size must be greater than 1. Please reenter: Array size must be greater than 1. -1 Please reenter: Please reenter: Array size must be greater than 1. 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 Exit 1 nmin 0 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 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 Exit 3

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 Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

Students also viewed these Databases questions