Advertisement
KeeJayBe

PROG1: determinant berekenen v 2x2 matrix

Nov 21st, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. /*
  2.  * KK    KK  JJJJJJJJJJ  BBBBBBBB
  3.  * KK  KK            JJ  BB      BB
  4.  * KKKK              JJ  BBBBBBBB
  5.  * KK  KK    JJ      JJ  BB      BB
  6.  * KK    KK    JJJJJJ    BBBBBBBBBB
  7.  *
  8.  * Copyright 2018 Jordy Van Kerkvoorde
  9.  */
  10. package h7;
  11.  
  12. import java.util.Scanner;
  13.  
  14. /**
  15.  *
  16.  * @author KeeJayBe
  17.  */
  18. public class Matrix {
  19.     public static void main(String[] args) {
  20.         Scanner s = new Scanner(System.in);
  21.         int[][] matrix = new int[2][2];
  22.         for(int i=0 ; i<=1; i++){
  23.             for(int j=0; j<=1; j++){
  24.             System.out.println("Geef een getal voor de rij" + (i + 1) +  "kolom " + (j+1) +": ");
  25.             int get = s.nextInt();
  26.             matrix[i][j] = get;
  27.             }
  28.         }
  29.        
  30.         int det = (matrix[0][0] * matrix [1][1]) - (matrix[0][1] * matrix[1][0]);
  31.         System.out.println("De determinant is: " + det);
  32.     }
  33.    
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement