Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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;
- /**
- *
- * @author ACER
- */
- import java.util.Scanner;
- public class Array {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- String[] name = {"Adam", "Dzaki", "Farras", "Obing"};
- String[] nim = {"001", "002", "003", "004"};
- String[] phonenumber = {"081234567890", "081234567891", "081234567892", "081234567893"};
- String[] kelas = {"SI-42-INT","SI-42-10","SI-42-09","SI-42-08"};
- System.out.println("================================== STUDENT DATA =================================================");
- System.out.println("----------------------------------------------");
- System.out.println("| No | NIM | NAMA | PHONE NUMBER | CLASS |");
- for (int i = 1; i <= 4; i++) {
- System.out.println("-------------------------------------------");
- System.out.println("| " + i + " | " + nim[i - 1] + " | " + name[i - 1] + " | " + phonenumber[i - 1] + " | " + kelas[i - 1] + " | ");
- }
- int ketemu=0;
- int index[]=new int[4];
- System.out.println("--------------------------------- FIND STUDENT ------------------------------------------- ");
- System.out.print("Masukkan NIM : "); String cari=in.next();
- for(int i=0;i<4;i++){
- if(nim[i].equals(cari)){
- index[ketemu]=i;
- ketemu++;
- }
- }
- //Menampilkan Data yang di Cari
- System.out.println("--------------------------------- REPORT------------------------------------------- ");
- if(ketemu > 0){
- System.out.println("data found...");
- System.out.println("--------------------------------");
- System.out.println("|No | NIM | NAME | PHONE NUMBER | CLASS |");
- System.out.println("--------------------------------");
- for(int a=1; a<=ketemu; a++){
- int s=index[a-1];
- System.out.println("| "+(index[a-1]+1)+" |"+nim[s]+" | "+name[s]+" | "+ phonenumber[s]+" |" + kelas[s]+"|");
- }System.out.println("+-------------------------------");
- }
- else{
- System.out.println("Maaf NIM "+cari+" yang anda cari tidak ada");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement