4x4 matrix in java programming

Programming
Tutor: None Selected Time limit: 1 Day

    int [][] matrix = new int [4][4];

    for(int i=0;i<4;i++){

        for(int j=0;j<4;j++){

            System.out.println(matrix[i][j]);

This is what I entered but just got a bunch of zeroes. I need the matrix to be 4x4 with the numbers 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16. When I run the program it needs to show the matrix, "Sum of row 1:", "Sum of row 2:" (as well as row 3 and 4), "Sum of column 1:" (and the rest of the columns), and sum of diagonals. 

Oct 3rd, 2015

Thank you for the opportunity to help you with your question!

 you should write this program : 

to fulll the matrix : 

       Scanner  input = new Scanner(System.in);

 int [][] matrix = new int [4][4];

    for(int i=0;i<4;i++){

        for(int j=0;j<4;j++){

            System.out.println("Enter the vlaue : ");

          matrix[i][j] = input.nextLine();

}

}


and you should write this to output the value : 

 for(int i=0;i<4;i++){

        for(int j=0;j<4;j++){

            System.out.print(" "+matrix[i][j]);

             }

     System.out.println(" ");

}


and you wiill get it as you want ok 

just ask if you need something 

Good Luck 


Please let me know if you need any clarification. I'm always happy to answer your questions.
Sep 21st, 2015

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Oct 3rd, 2015
...
Oct 3rd, 2015
Dec 7th, 2016
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer