My assignment is to

Write a method that returns the sum of all the elements in a specified column in a matrix using the following header:

public stat double sumColumn(double[][] m, int columnIndex

Also write a test program that reads a 3-by-4 matrix and displays the sum of each column.

And this is what I have so far

import java.util.Scanner; public class Matrix{ public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a 3 by 4 matrix row by row: "); double[][] m = new double[3][4]; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) m[i][j] = input.nextDouble(); } public static double sumColumn(double[][] m, int columnIndex) { int sum = 0; for (int i = 0; i < m.length; i++) total += m [i][j]; System.out.println("Sum for column" + i + " is " + total); } }