SHARE
TWEET

Untitled

a guest Nov 19th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package pertemuan7;
  2. import java.util.Scanner;
  3.  
  4. public class Pertemuan7 {
  5. static Scanner A=new Scanner(System.in);
  6.    
  7.     public static void main(String[] args) {
  8.         int m,n;
  9.         System.out.print("Masukan jumlah baris : ");
  10.         m = A.nextInt();
  11.         System.out.print("Masukan jumlah kolom : ");
  12.         n = A.nextInt();
  13.         int matriksA[][] = new int[m][n];
  14.         int matriksB[][] = new int[m][n];
  15.         System.out.println("");
  16.        
  17.         System.out.println("Input Matriks A");
  18.         for(int i=0; i<m;i++){
  19.             for(int j=0;j<n;j++){
  20.                 System.out.print("["+(i+1)+"]["+(j+1)+ "]=");
  21.                 matriksA[i][j]=A.nextInt();
  22.             }
  23.             System.out.println("");
  24.         }
  25.         System.out.println("Matriks A");
  26.         for(int i=0;i<matriksA.length;i++){
  27.             for(int j=0;j<matriksA.length;j++){
  28.                 System.out.print(matriksA[i][j]+" ");
  29.             }
  30.             System.out.println("");
  31.         }
  32.         System.out.println("");
  33.         System.out.println("Input Matriks B");
  34.         for(int i=0; i<m;i++){
  35.             for(int j=0;j<n;j++){
  36.                 System.out.print("["+(i+1)+"]["+(j+1)+ "]=");
  37.                 matriksB[i][j]=A.nextInt();
  38.             }
  39.             System.out.println("");
  40.         }
  41.         System.out.println("Matriks B");
  42.         for(int i=0;i<matriksB.length;i++){
  43.             for(int j=0;j<matriksB.length;j++){
  44.                 System.out.print(matriksB[i][j]+" ");
  45.             }
  46.             System.out.println("");
  47.         }
  48.         System.out.println("");
  49.         System.out.println("Penjumlahan Matriks A + Matriks B");
  50.         for(int i=0;i<matriksA.length;i++){
  51.             for(int j=0;j<matriksA.length;j++){
  52.                 System.out.print(matriksA[i][j]+matriksB[i][j]+" ");
  53.             }
  54.             System.out.println("");
  55.         }
  56.     }
  57.    
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top