Question: JAVA- How do I edit this code to combine all the methods into one main method? Sample input/output below: import java.util.Scanner; public class Prog7 {

JAVA- How do I edit this code to combine all the methods into one main method? Sample input/output below:

JAVA- How do I edit this code to combine all the methods

import java.util.Scanner;

public class Prog7 { public static void main(String[] args) Scanner reader = new Scanner(System.in);

// reading dimension int n = reader.nextInt();

// creating 2D array int [][] matrix = new int[n][n];

// reading in matrix int i=0;

while(reader.hasNext()){ int j = 0;

while(j

j++; } i++; } // array to store row and column sum

int rowSum[] = new int[n]; int colSum[] = new int[n];

// row sum

for (int r = 0; r

for (int c = 0; c

sum += matrix[r][c];

} rowSum[r] = sum; }

// col sum

for (int c = 0; c

for (int r = 0; r

colSum[c] = sum; }

// display

for (int r = 0; r

for (int c = 0; c

System.out.println(" : "+rowSum[r]); }

System.out.println("---------------------------");

for(int c=0; c

}

public static void averageEachRow(int[][] matrix) { int row = matrix.length; int col = matrix[0].length;

for (int i = 0; i

for (int j = 0; j

System.out.println("Average of " + (i + 1) + " row: " + String.format("%.3f", sum /col)); } }

public static void averageEachCol(int[][] matrix) { int row = matrix.length; int col = matrix[0].length;

for (int i = 0; i

for (int j = 0; j

System.out.println("Average of " + (i + 1) + " column: " + String.format("%.3f", sum /row)); } }

o 3 9 3 99 3 4 3 5 5 1 1 3 2 14 3 9 9 3 24 4 3 5 17 1 1 2 7 11 8 16 25 17 o 3 9 2 8 8 3 99 3 1 2 4 3 5 5 3 4 1 1 7 9 8 9 3 9 File in dat cution File in2.dat

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!