Question
Write a program that prompts a user to enter data for an array. The user should be able to input ANY primitive data type (int,
Write a program that prompts a user to enter data for an array. The user should be able to input ANY primitive data type (int, float, double, long). The program should also have the following methods:
getTotal. This method should accept a one-dimensional array as its argument and return the total of the values in the array.
GetAverage. This method should accept a one-dimensional array as its argument and return the average of the values in the array.
GetHighest. This method should accept a one-dimensional array as its argument and return the highest of the values in the array.
GetLowest. This method should accept a one-dimensional array as its argument and return the lowest of the values in the array.
Example input and output
Enter Data Type: INT (Enter -999 to stop)
Enter Integers: (Enter -999 to stop) 2
Enter Integer: 3
Enter Integer: 4
Enter Integer: 5
Enter Integer: -999
Processing the int array.
Total : 14
Average : 4
Highest value : 5
Lowest value : 2
Enter Data Type: DOUBLE (Enter -999 to stop)
Enter Double: (Enter -999 to stop) 2.5
Enter Double: 2.4
Enter Double: 2.3
Enter Double: 2.2
Enter Double: -999
Processing the Double array.
Total : 9.4
Average : 2.35
Highest value : 2.5
Lowest value : 2.2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started