Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/** 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

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

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago