Question: Write a program that creates a two - dimensional array initialized with test data. Use any primitive data type that you wish. The program should

Write a program that creates a two-dimensional array initialized with test data. Use any primitive data type that you wish. The program should have the following methods:
getTotal. This method should accept a two-dimensional array as its argument and return the total of all the values in the array.
getAverage. This method should accept a two-dimensional array as its argument and return the average of all the values in the array.
getRowTotal. This method should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The method should return the total of the values in the specified row.
getColumnTotal. This method should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a column in the array. The method should return the total of the values in the specified column.
getHighestInRow. This method should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The method should return the highest value in the specified row of the array.
getLowestInRow. This method should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array1) Use the following double array as test data:
double[][] darray ={{98.7,89.2,55.1},
{77.6,99.9,62.2},
{56.9,87.3,43.7}};
2) One class should be fine and can be named as ArrayOperations2DDemo, run the following statements on the double array provided above.
System.out.println("
Processing the double array.");
System.out.printf("Total : %.2f
", getTotal(darray));
System.out.printf("Average : %.2f
", getAverage(darray));
System.out.printf("Total of row 0(first row): %.2f
", getRowTotal(darray,0));
System.out.printf("Total of col 2(third col): %.2f
", getColumnTotal(darray,2));
System.out.printf("Highest in row 0(first row): %.2f
", getHighestInRow(darray,0));
System.out.printf("Lowest in row 2(third row): %.2f
", getLowestInRow(darray,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!