Kamis, 23 November 2017

ARRAY 2 DIMENSI



/*
 * 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.
 */
package array.pkg2.dimensi;

import java.util.Scanner;

/**
 *
 * @author USER
 */
public class Array2Dimensi {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Scanner nextInt = new Scanner(System.in);
        Scanner nextLine = new Scanner(System.in);
        int[][] nilai = new int[3][3];
    int baris,kolom = 0;
   
    System.out.println("");
    for(baris=0;baris<nilai.length;baris++){
        for(kolom=0;kolom<nilai[baris].length;kolom++){
        Scanner bacaRecord = new Scanner(System.in);
        System.out.print("Input nilai Tabel baris["+baris+"]kolom["+kolom+"]=");
        nilai[baris][kolom]= bacaRecord.nextInt();
        }
    }
   
    System.out.println("\n--------------Hasil nilai------------------");
    for(baris=0;baris<nilai.length;baris++){
        for(kolom=0;kolom<nilai[baris].length;kolom++){
        System.out.print("|"+nilai[baris][kolom]);
    }
   
    System.out.print("|\n");  
    }
    System.out.println("-----------------------------------------");
    }
}

Tidak ada komentar:

Posting Komentar