Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 4 (name this Lab7 _Problem4) (Java Program) Write a Java program that cr

ID: 3757676 • Letter: P

Question

Problem 4 (name this Lab7 _Problem4)

(Java Program)

Write a Java program that creates the following matrix by adding 3 to the previous value, then displays it. The matrix has 6 rows and 4 columns. Allow for a fixed width of 6 horizontal columns for each value in the display. Notice the digits are right aligned. Base your solution on nested for loops. Code this as a single main() method (i.e., do not use any additional methods for this problem).

0     3     6     9

12    15    18    21

24    27    30    33

36    39    42    45

48    51    54    57

60    63    66    69

Explanation / Answer

[code] import java.util.Scanner; public class SumElementsColumnByColumnClass { public static void main(String[] args) { double[][] m = createArray(); int i = 0; double sum = sumColumn(m, i); System.out.println("Sum of the elements at column " + i + " is " + sum); } public static double[][] createArray(){ Scanner input = new Scanner(System.in); double[][] m = new double[3][4]; System.out.println("Enter a " + m.length + "-by-" + m[0].length + " matrix row by row: "); for (int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote