Write a method called printArray With Totals that accepts a

Write a method called printArray With Totals that accepts a reference to a two-dimensional array of integers as a parameter and displays the elements of the two-dimensional array as a table with an extra column for the row totals as the rightmost column and an extra row for the column totals as the bottom row. (Write your own code for all of these computations. Do not call any methods that come with Java that operate on entire arrays.)

Solution

public void printGrid()
{
for(int i = 0; i < 20; i++)
{
for(int j = 0; j < 20; j++)
{
System.out.printf(\"%5d \", a[i][j]);
}
System.out.println();
int rows = a.length;
int cols = [0].length;
System.out.println(\"No.of rows\",rows);
System.out.println(\"No.of Columns\",cols);
}
}

 Write a method called printArray With Totals that accepts a reference to a two-dimensional array of integers as a parameter and displays the elements of the tw

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site