Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please enter a seed: 6543 Please enter the size of the array: -1 Array size must be greater than 1. Please reenter: -5 Array size

Please enter a seed: 6543

Please enter the size of the array: -1

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

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

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 Swap the first and last elements

6 Circular shift to the left

7 Exit

1

Array: 1 4 4 2 2 3 4 4 0 3

This Minilab will review numerous basic topics, including constants, keyboard input, loops, menu input, 1-dimensional arrays, and creating/using instances of classes.

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 integer that the array can contain (8) and the integer whose occurrances will be counted (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 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 ReviewExample.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 of the outputs (Array: ) or (Length: ) or (prompts)

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

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

Power Bi And Azure Integrating Cloud Analytics For Scalable Solutions

Authors: Kiet Huynh

1st Edition

B0CMHKB85L, 979-8868959943

More Books

Students also viewed these Databases questions

Question

List the three major factors that influence attraction.

Answered: 1 week ago