/** Create a program that prompts the user for a number of rows and number of co
ID: 3669117 • Letter: #
Question
/**
Create a program that prompts the user for a number of rows and number of columns to create a 2 dimensional array (matrix) of integer values. Then ask the user for each value in the matrix. After you get those values, print the matrix with row averages, then print a second time with column averages. KEEEP ALL NUMBERS as INTEGER.
Submit one java file.
be sure the user inputs two integers and then numbers for the matrix. Hint: no strings allowed or dimensions as decimal numbers.
sample output that gets 10 extra points:
3.0, 3.0, 3.0, 3.0, avg = 3.0
7.0, 7.0, 7.0, 7.0, avg = 7.0
9.0, 9.0, 9.0, 9.0, avg = 9.0
avg= 6.3, 6.3, 6.3, 6.3,
Please modify the code below to print the average of each row
and the average of each column.
*/
*/
import java.util.Scanner;
class MatrixLab_start
{
public static void main(String[] args)
{
int[][] M = {
{4,5,6,7},
{1,2,3,4},
{8,11,13,2}};
int rows=M.length;
int cols=M[0].length;
for(int i=0; i {
for(int k=0; k {
System.out.printf("%3d ,",M[i][k]);
}
System.out.println();
}
}
}
Explanation / Answer
System.out.println("Avg of colms : "+s/array.length);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.