Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Lab 1 3 A: Write the three static methods below inside of your driver class ( this is the class that contains your main

JAVA
Lab13A: Write the three static methods below inside of your driver class (this is the class that contains your main method):
min(): Receives an integer array as a parameter and returns an integer. This method traverses the array in the parameters and returns the smallest number in the array.
max(): Receives an integer array as a parameter and returns an integer. This method traverses the array in the parameters and returns the largest number in the array.
avg(): Receives an integer array as a parameter and returns a double. This method traverses the array in the parameters and returns the mean average of the numbers in the array.
Inside your main method, prompt the user for a size for the array you are about to create; keep prompting the user if they enter a size thats less than 1. Once the user enters a valid number, create an integer array of that size.
Next, prompt the user for enough numbers to fill the whole array. These numbers can be positive, negative, or 0.
Next, ask the user if they want to find the smallest, the largest, or the mean average of all the numbers theyve entered (keep prompting the user until they enter a valid choice). Pass the array to the appropriate method and print the results.
Keep asking the user for an option until they enter the option to quit.
You can assume that the user will not enter doubles or strings when prompted for a number.
Sample input on the next page.
Sample output (user input in bold):
How many numbers would you like to enter? -30
You must enter a value that is greater than 0.
How many numbers would you like to enter? 0
You must enter a value that is greater than 0.
How many numbers would you like to enter? 5
Enter number 0: 6
Enter number 1: -99
Enter number 2: 37
Enter number 3: 2000
Enter number 4: 81
1- Find the smallest of the numbers entered
2- Find the largest of the numbers entered
3- Find the average of the numbers entered
4- Quit
Enter your option: 1
The smallest of the numbers you entered is -99
1- Find the smallest of the numbers entered
2- Find the largest of the numbers entered
3- Find the average of the numbers entered
4- Quit
Enter your option: 2
The largest of the numbers you entered is 2000
1- Find the smallest of the numbers entered
2- Find the largest of the numbers entered
3- Find the average of the numbers entered
4- Quit
Enter your option: 3
The average of the numbers you entered is 405.0
1- Find the smallest of the numbers entered
2- Find the largest of the numbers entered
3- Find the average of the numbers entered
4- Quit
Enter your option: 5
That is not a valid option!
1- Find the smallest of the numbers entered
2- Find the largest of the numbers entered
3- Find the average of the numbers entered
4- Quit
Enter your option: 4
Shutting off...

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

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

Evaluate each of the following. 3 -2

Answered: 1 week ago

Question

Describe factors that influence training and development.

Answered: 1 week ago

Question

Identify some training issues in the global context.

Answered: 1 week ago