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
/**
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(); } } }
Can anyone modify exactly the same code, please no new context. Would be grateful if modified same codes. I tried to compile this code in Dr.Java but its giving too many errors
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started