Summation of two matrices can be expressed as summation of the individual elements in the same...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Summation of two matrices can be expressed as summation of the individual elements in the same position in two matrices. Only matrices with the same shape can be summed. 2 6 0 1 -3 0 1 10 -10 5 0 1 0 5 -1 2 + 242 0 Matrix 1: 4 16 12 75 75 81 37 2 1 19 96 27 0 5 1 6 Sample Case: Number of rows: 3 Number of columns: 4 0 -10 1 5 1 5 -1 2 0 10 2 1 -3 15 1 6 0 2 -20 10 2 10 4 Write a Java program that will calculate summation of two matrices. The program should initially ask the user to enter number of rows and columns. Then, it will create two matrices with the given sizes. Matrices are defined using two dimensional integer arrays. The created matrices should be filled with random integer values between 0 and 100. Then, the matrices should be printed with a printMatrix method which has the following signature. -2 public static void printMatrix (int[][] m) This method will receive a two dimensional integer array and print it in the format given in the sample case. Summation of two matrices can be expressed as summation of the individual elements in the same position in two matrices. Only matrices with the same shape can be summed. 2 6 0 1 -3 0 1 10 -10 5 0 1 0 5 -1 2 + 242 0 Matrix 1: 4 16 12 75 75 81 37 2 1 19 96 27 0 5 1 6 Sample Case: Number of rows: 3 Number of columns: 4 0 -10 1 5 1 5 -1 2 0 10 2 1 -3 15 1 6 0 2 -20 10 2 10 4 Write a Java program that will calculate summation of two matrices. The program should initially ask the user to enter number of rows and columns. Then, it will create two matrices with the given sizes. Matrices are defined using two dimensional integer arrays. The created matrices should be filled with random integer values between 0 and 100. Then, the matrices should be printed with a printMatrix method which has the following signature. -2 public static void printMatrix (int[][] m) This method will receive a two dimensional integer array and print it in the format given in the sample case.
Expert Answer:
Answer rating: 100% (QA)
Java import javautilRandom public class MatrixSummation public static void mainString args Get the number of rows and columns from the user SystemoutprintlnEnter the number of rows int rows Integerpar... View the full answer
Related Book For
Calculus Of A Single Variable
ISBN: 9781337275361
11th Edition
Authors: Ron Larson, Bruce H. Edwards
Posted Date:
Students also viewed these programming questions
-
In October, Carla Vista Company reports 20,600 actual direct labor hours, and it incurs $213,300 of manufacturing overhead costs. Standard hours allowed for the work done is 23,700 hours. The...
-
9.1 Exercise (JDK Source Code): Extract the source code of the class Math from the JDK source code ("$JAVA_HOME" "src.zip" "Math.java" under folder "java.lang"). Study how constants such as E and...
-
You have now been asked to work with a textile startup business that your firm has just taken on as a client. The business is particularly in need of support and guidance with budgeting and how it...
-
Determine the force in members HI, FI, and EF of the truss, and state if the members are in tension orcompression. 3 m D. -2 m--2 m2 m--2 m--2 m--2 m- 4 kN 5 KN 6 kN 8 kN
-
Rework Exercise 95 with a 2015 fixed cost of $800,000 and a profit before income taxes of $300,000.
-
On June 30, 2013, Sharper Corporations common stock is priced at $ 62 per share before any stock dividend or split, and the stockholders equity section of its balance sheet appears as follows. Common...
-
Derive the finite difference equations for the forced vibration of a fixed-fixed uniform shaft under torsion, using a total of \(n\) mesh points.
-
On January 4, 2014, Glennside Co. paid $235,000 for a computer system. In addition to the basic purchase price, the company paid a setup fee of $1,100, $6,200 sales tax, and $37,200 for a special...
-
2. Write a C program, problem1.c, to read in a text file, called text.txt, and build a concordance file, called concordance.txt, for the file showing the number of unique words, the unique words, and...
-
In 1913, how long did the average worker stay with the plant? What was the average tenure of a worker? Assume the one-millionth vehicle was produced in 1916 at a cost of $8084 (in 2013 US$). By how...
-
1) Firm B has a monopoly for product X because of a license of the state. Suppose that the marginal cost curve of B is ascending and that it makes a profit. a) Draw a diagram with demand curve,...
-
Which of the following is an example of a conflict of interest that an effective corporate governance system would mitigate or eliminate? A. A majority of the board is independent of management. B....
-
All of the following are true of an effective system of corporate governance except: A. the system must be continually monitored especially with changes in management and the board. B. a single...
-
Which of the following best defines the concept of corporate governance? A. A system for monitoring managers activities, rewarding performance, and disciplining misbehavior. B. Corporate values and...
-
Given that Zeros directors all previously worked at the company, which of the following would you recommend for a more effective system of corporate governance? A. Ensure that assets are used...
-
What are the two traditional service line costing methods?
-
Draft an explanation of the topic Bond Markets that will be used for reporting. Follow the Outline of the topic which can be found on the first page of the PDF, on the left side. The outline consists...
-
Using a graphing utility, graph y = cot -1 x.
-
In Exercises 39 and 40, find the work done by the force field F on a particle moving along the given path. F(x, y) = xi vi C: x = 1, y = 13/2 from (0, 0) to (4,8)
-
Determine whether f(x) approaches or as x approaches 4 from the left and from the right. f(x) = 1 x 4
-
Consider the series (a) Verify that the series converges. (b) Use a graphing utility to complete the table. (c) The sum of the series is 2 /8. Find the sum of the series (d) Use a graphing utility...
-
What are vertical and horizontal financial statement analyses? What are their advantages?
-
Which form of financing requires repayment, regardless of whether the company receiving the funds does well or not? a. A loan b. An investment c. Both a loan and an investment d. Neither a loan nor...
-
Which form of financing allows the source of the funds to share in the wealth if the company which received the financing does well? a. A loan b. An investment c. Both a loan and an investment d....
Study smarter with the SolutionInn App