Operasi array matriks
import javax.swing.JOptionPane;
/**
*
* @author Zed
*/
public class Operasi_Matriks {
public static void main(String[] args) {
System.out.println("Operasi Matriks");
int row = Integer.parseInt(JOptionPane.showInputDialog(null,"Masukkan Jumlah Baris: "));
int col = Integer.parseInt(JOptionPane.showInputDialog(null,"Masukkan Jumlah Kolom: "));
double A[][] = new double[row][col];
double B[][] = new double[row][col];
double C[][] = new double[row][col];
double D[][] = new double[row][col];
int i,j,k;
System.out.println("\nMatriks A");
for(i=0;i
System.out.print("| ");
for(j=0;j
A[i][j] = Double.parseDouble(JOptionPane.showInputDialog(null,"Masukkan Matriks A ["+(i+1)+","+(j+1)+"]"));
System.out.print(" "+A[i][j]+" ");
}
System.out.println(" |");
}
System.out.println("\nMatriks B");
for(i=0;i
System.out.print("| ");
for(j=0;j
B[i][j] = Double.parseDouble(JOptionPane.showInputDialog(null,"Masukkan Matriks B ["+(i+1)+","+(j+1)+"]"));
System.out.print(" "+B[i][j]+" ");
}
System.out.println(" |");
}
System.out.println("\nPenjumlahan Matriks");
System.out.println("Matriks A + B =");
for(i=0;i
System.out.print(" | ");
for(j=0;j
for(k=0;k
C[i][j] = (A[i][j]+B[i][j]);
}
System.out.print(" "+C[i][j]+" ");
}
System.out.println(" | ");
}
System.out.println("\nPengurangan Matriks");
System.out.println("Matriks A - B =");
for(i=0;i
System.out.print(" | ");
for(j=0;j
for(k=0;k
C[i][j] = (A[i][j]-B[i][j]);
}
System.out.print(" "+C[i][j]+" ");
}
System.out.println(" | ");
}
System.out.println("\nPerkalian Matriks");
System.out.println("Matriks A x B =");
for(i=0;i
System.out.print(" | ");
for(j=0;j
for(k=0;k
D[i][j] = D[i][j]+(A[i][k] * B[k][j]);
}
System.out.print(" "+D[i][j]+" ");
}
System.out.println(" | ");
}
}
}|
|
|
|
|
|
|
|
|
/**
*
* @author Zed
*/
public class Operasi_Matriks {
public static void main(String[] args) {
System.out.println("Operasi Matriks");
int row = Integer.parseInt(JOptionPane.showInputDialog(null,"Masukkan Jumlah Baris: "));
int col = Integer.parseInt(JOptionPane.showInputDialog(null,"Masukkan Jumlah Kolom: "));
double A[][] = new double[row][col];
double B[][] = new double[row][col];
double C[][] = new double[row][col];
double D[][] = new double[row][col];
int i,j,k;
System.out.println("\nMatriks A");
for(i=0;i
System.out.print("| ");
for(j=0;j
A[i][j] = Double.parseDouble(JOptionPane.showInputDialog(null,"Masukkan Matriks A ["+(i+1)+","+(j+1)+"]"));
System.out.print(" "+A[i][j]+" ");
}
System.out.println(" |");
}
System.out.println("\nMatriks B");
for(i=0;i
System.out.print("| ");
for(j=0;j
B[i][j] = Double.parseDouble(JOptionPane.showInputDialog(null,"Masukkan Matriks B ["+(i+1)+","+(j+1)+"]"));
System.out.print(" "+B[i][j]+" ");
}
System.out.println(" |");
}
System.out.println("\nPenjumlahan Matriks");
System.out.println("Matriks A + B =");
for(i=0;i
System.out.print(" | ");
for(j=0;j
for(k=0;k
C[i][j] = (A[i][j]+B[i][j]);
}
System.out.print(" "+C[i][j]+" ");
}
System.out.println(" | ");
}
System.out.println("\nPengurangan Matriks");
System.out.println("Matriks A - B =");
for(i=0;i
System.out.print(" | ");
for(j=0;j
for(k=0;k
C[i][j] = (A[i][j]-B[i][j]);
}
System.out.print(" "+C[i][j]+" ");
}
System.out.println(" | ");
}
System.out.println("\nPerkalian Matriks");
System.out.println("Matriks A x B =");
for(i=0;i
System.out.print(" | ");
for(j=0;j
for(k=0;k
D[i][j] = D[i][j]+(A[i][k] * B[k][j]);
}
System.out.print(" "+D[i][j]+" ");
}
System.out.println(" | ");
}
}
}
Tidak ada komentar:
Posting Komentar