array penjumlahan matriks

import java.util.Scanner;
class array3{
public static void main(String[]args)throws Exception{

Scanner masuk = new Scanner(System.in);
int baris,kolom,k=0;
System.out.print(“masukkan indeks baris: “);
baris = masuk.nextInt();
System.out.print(“masukkan indeks kolom: “);
kolom = masuk.nextInt();

int A[][] = new int [baris][kolom];
System.out.println(“\nNilai A “);
for(int i=0;i<baris;i++){
for(int j=0;j<kolom;j++){
System.out.print(“baris ke- “+(i+1)+”, kolom ke-“+(j+1)+” “);
A[i][j] = masuk.nextInt();
}}

System.out.print(“\n”);

int B[][] = new int [baris][kolom];
System.out.println(“Nilai B “);
for(int i=0;i<baris;i++){
for(int j=0;j<kolom;j++){
System.out.print(“baris ke-“+(i+1)+”, kolom ke-“+(j+1)+” : “);
B[i][j] = masuk.nextInt();
}}

System.out.print(“\n”);
System.out.println(“Nilai A “);
for(int i=0;i<baris;i++){
System.out.print(“|”);
for(int j=0;j<kolom;j++){
System.out.print(A[i][j]+” “);
}
System.out.println(“|”);
}
System.out.println(“Nilai B “);
for(int i=0;i<baris;i++){
System.out.print(“|”);
for(int j=0;j<kolom;j++){
System.out.print(B[i][j]+” “);
}
System.out.println(“|”);
}
System.out.println(“penjumlahan array “);
for(int i=0;i<baris;i++){
System.out.print(“|”);
for(int j=0;j<kolom;j++){
System.out.print(A[i][j]+B[i][j]+” “);
}
System.out.println(“|”);
}
}}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s