0

Determinant counting program

I`m doing a program that calculates determinants, but something wrong with my code. Class Three() is not working in main cases. import java.util.Scanner; public class Determinant { public static double Three(int arr[][]) { double det = 3; for (byte i = 0; i <= 2; i++) for (byte j = 0; j <= 2; j++) det = (arr[1][1] * arr[2][2] * arr[3][3]) + (arr[1][2] * arr[2][3] * arr[3][1] + arr[2][1] * arr[3][2] * arr[1][3]) - ((arr[3][1] * arr[2][2] * arr[1][3] + arr[2][1] * arr[1][2] * arr[3][3]) + (arr[3][2] * arr[2][3] * arr[1][1])); return det; } public static double Four() { double det = 4; return det; } public static double Five() { double det = 5; return det; } public static void main(String[] args){ byte i; byte j; int[][] a = new int[5][5]; Scanner input = new Scanner(System.in); System.out.println("Enter capacity of the matrix (3-5):"); i = input.nextByte(); switch (i) { case 3: for (i=0;i<=2;i++) for (j=0;j<=2;j++) a[i][j] = input.nextInt(); Three(a[][]); break; case 4: Four(); break; case 5: Five(); break; default: System.out.println("Enter 3-5 matrix."); } input.close(); } }

27th Sep 2019, 6:38 PM
Suspense
Suspense - avatar
1 Odpowiedź
0
in main case 3 // Three(a[][]); double result = Three(a); ... System.out.println(result);
27th Sep 2019, 7:56 PM
zemiak