Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions

Question

passionate about her work?

Answered: 1 week ago

Question

7. Discuss the key features of the learning organization.

Answered: 1 week ago