Soal :
Jawab :
/*
*
To change this license header, choose License Headers in Project Properties.
*
To change this template file, choose Tools | Templates
*
and open the template in the editor.
*/
/**
*
*
@author ferri
*/
import
java.util.Scanner;
public
class PenjumlahanMatriks {
public static void main(String[] args){
Scanner ketik = new Scanner(System.in);
int A[][] = new int[2][2];
int B[][] = new int[2][2];
int C[][] = new int[2][2];
System.out.println("Matriks
A");
for(int i = 0; i<2; i++){
for(int j = 0; j<2; j++){
System.out.print("Baris
ke-" +(i+1)+ ",Kolom ke-" +(j+1)+ " : ");
A[i][j] = ketik.nextInt();
}
}
System.out.println("Matriks
B");
for(int k=0; k<2; k++){
for(int l=0; l<2; l++){
System.out.print("Baris
ke-" +(k+1)+ ",Kolom ke-" +(l+1)+ " : ");
B[k][l] = ketik.nextInt();
}
for(int x = 0; x<2; x++){
for(int y = 0; y<2; y++){
C[x][y] = A[x][y]+B[x][y];
}
}
}
System.out.println("Hasil A +
B");
for(int x = 0; x<2; x++){
System.out.print(+(C[x][y])+" ");
}
System.out.println(" ");
}
}