daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Dec 19th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Array {
  4.  
  5.     public static void main(String[] args) {
  6.         int jumlahBaris, jumlahKolom;
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         System.out.print("Masukan Jumlah indeks baris martriks : ");
  10.         jumlahBaris = scanner.nextInt();
  11.         System.out.print("Masukan Jumlah indeks kolom martriks : ");
  12.         jumlahKolom = scanner.nextInt();
  13.         Integer[][] array = new Integer[jumlahBaris][jumlahKolom];
  14.  
  15.         for (int i = 0; i < jumlahBaris; i++) {
  16.             for (int j = 0; j < jumlahKolom; j++) {
  17.                 System.out.print("Masukan isi indeks beris ke " + i + " kolom ke "+j+":");
  18.                 array[i][j] = scanner.nextInt();
  19.             }
  20.         }
  21.  
  22.         System.out.println();
  23.         System.out.println("berikut adalah isi array yang tadi dimasukan:");
  24.         for (int i = 0; i < jumlahBaris; i++) {
  25.             for (int j = 0; j < jumlahKolom; j++) {
  26.                 System.out.println("Isi indeks baris ke " + i + " kolom ke "+j+" adalah :" + array[i][j]);
  27.             }
  28.  
  29.         }
  30.        
  31.          System.out.println();
  32.         System.out.println("Bentuk matriks:");
  33.         for (int i = 0; i < jumlahBaris; i++) {
  34.             for (int j = 0; j < jumlahKolom; j++) {
  35.                 System.out.print(array[i][j]+" ");
  36.             }
  37.             System.out.println();
  38.         }
  39.     }
  40. }
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
 
Top