class akhir{
public static void main(String []arg) throws Exception {
BufferedReader input = new BufferedReader (new InputStreamReader(System.in));
float temp;
System.out.println ("Mencari Determinan,Adjoin, Invers dan Transpose sebuah matrik");
System.out.println ("=============================================================");
System.out.println ("Ordo Matriks = 2*2");
float [][] matrika = new float [2][2];
System.out.println ("Masukan Elemen Matiksnya : ");
for (int i=0;i<2;i++){
for (int j=0;j<2;j++){
System.out.print ("Elemen matriks ["+(i+1)+","+(j+1)+"] = ");
matrika[i][j]=Float.parseFloat (input.readLine());
}
}
for (int i=0;i<2;i++){
System.out.print ("|");
for (int j=0;j<2;j++){
System.out.print (matrika[i][j]+" ");
}
System.out.println ("|");
}
float dtr=(matrika[0][0]*matrika[1][1])-(matrika[1][0]*matrika[0][1]);
System.out.println ("\nDeterminannya = "+dtr+"\n");
temp=matrika[0][0];
matrika[0][0]=matrika[1][1];
matrika[1][1]=temp;
matrika[0][1]=matrika[0][1]*-1;
matrika[1][0]=matrika[1][0]*-1;
System.out.println("Matriks Adjoint : ");
for (int i=0;i<2;i++){
System.out.print ("|");
for (int j=0;j<2;j++){
System.out.print (matrika[i][j]+" ");
}
System.out.println ("|");
}
System.out.println ("\nMatriks Inversnya : ");
for (int i=0;i<2;i++){
System.out.print ("|");
for (int j=0;j<2;j++){
System.out.print (matrika[i][j]/dtr+" ");
}
System.out.println ("|");
}
System.out.print("\nMasukan jumlah ordo matriks n*n = ");
int n=Integer.parseInt(input.readLine());
int [][] matrikb = new int [n][n];
int [][] matrikc = new int [n][n];
System.out.println("Matriks A:");
for(int i=0;i
}
}
System.out.print(" system.out.print(matrikb[i][j]+="" \n="" matriks="" transpose="" a="" i="0;i<n;i++)" system.out.print(="" for(int="" j="0;j<n;j++)" {="" matrikc[i][j]="matrikb[j][i];" system.out.print(matrikc[i][j]+="" system.out.println(="" |="" );="" }="">
Tidak ada komentar:
Posting Komentar