Mempelajari Matrik Pada Program Java

Bookmark and Share

Matrik pada Program java

import java.io.*;

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

{ 0 komentar... Views All / Send Comment! }

Posting Komentar