public class matrik
{
public static void main(String[]args)
{
System.out.println("Matriks A : \n");
int baris=Integer.parseInt(javax.swing.JOptionPane.showInputDialog(null,"Masukan Banyak Baris Untuk Matrik : ","2"));
int kolom=Integer.parseInt(javax.swing.JOptionPane.showInputDialog(null,"Masukan Banyak Kolom Untuk Matrik: ","2"));
int skalar=Integer.parseInt(javax.swing.JOptionPane.showInputDialog(null,"Masukan Nilai Skalar: ","2"));
int A[][]=new int[baris][kolom];
for(int i=0;i <>
{
System.out.print("|");
for(int j=0;j <>
{
A[i][j]=Integer.parseInt(javax.swing.JOptionPane.showInputDialog(null,"Nilai A Baris Ke-"+(i+1)+", Kolom Ke-"+(j+1)+" = ","0"));
System.out.print(" "+A[i][j]+" ");
}
System.out.println("|");
}
System.out.println("\n");
System.out.println("Matriks B : \n");
int B[][]=new int[baris][kolom];
for(int i=0; i <>
{
System.out.print("|");
for(int j=0; j <>
{
B[i][j]=Integer.parseInt(javax.swing.JOptionPane.showInputDialog(null,"Nilai B Baris Ke-"+(i+1)+", Kolom Ke-"+(j+1)+" = ","0"));
System.out.print(" "+B[i][j]+" ");
}
System.out.println("|");
}
System.out.println("\n");
System.out.println("===============================");
System.out.println("Operasi Matrik Penjumlahan :");
System.out.println("===============================");
for(int i=0;i <>
System.out.print("|");
for(int j=0;j <>
System.out.print(" "+(A[i][j]+B[i][j])+" ");
}
System.out.println("|");
}
System.out.println("\n");
System.out.println("===============================");
System.out.println("Operasi Matrik Pengurangan :");
System.out.println("===============================");
for(int i=0;i <>
System.out.print("|");
for(int j=0;j <>
System.out.print(" "+(A[i][j]-B[i][j])+" ");
}
System.out.println("|");
}
System.out.println("\n");
System.out.println("================================");
System.out.println("Operasi Matrik Perkalian Skalar :");
System.out.println("================================");
for(int i=0; i <>
System.out.print("|");
for(int j=0;j <>
System.out.print(" "+(skalar*A[i][j]+skalar*B[i][j])+" ");
}
System.out.println("|");
}
System.out.println("\n");
}
}
Tidak ada komentar:
Posting Komentar