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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!