# Hey guys I need some help

• October 25th, 2012, 10:46 PM
kenamine
Hey guys I need some help
http://i49.tinypic.com/9hs9j7.png

Code :

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

what did I do wrong?
• October 25th, 2012, 10:53 PM
kenamine
Re: Hey guys I need some help
• October 25th, 2012, 11:10 PM
kenamine
Re: Hey guys I need some help
nvm I got it now!
Code :

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