Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package array;
  7.  
  8. /**
  9. *
  10. * @author ACER
  11. */
  12. import java.util.Scanner;
  13.  
  14. public class Array {
  15.  
  16. /**
  17. * @param args the command line arguments
  18. */
  19. public static void main(String[] args) {
  20. Scanner in = new Scanner(System.in);
  21.  
  22. String[] name = {"Adam", "Dzaki", "Farras", "Obing"};
  23. String[] nim = {"001", "002", "003", "004"};
  24. String[] phonenumber = {"081234567890", "081234567891", "081234567892", "081234567893"};
  25. String[] kelas = {"SI-42-INT","SI-42-10","SI-42-09","SI-42-08"};
  26. System.out.println("================================== STUDENT DATA =================================================");
  27. System.out.println("----------------------------------------------");
  28. System.out.println("| No | NIM | NAMA | PHONE NUMBER | CLASS |");
  29. for (int i = 1; i <= 4; i++) {
  30. System.out.println("-------------------------------------------");
  31. System.out.println("| " + i + " | " + nim[i - 1] + " | " + name[i - 1] + " | " + phonenumber[i - 1] + " | " + kelas[i - 1] + " | ");
  32. }
  33. int ketemu=0;
  34. int index[]=new int[4];
  35. System.out.println("--------------------------------- FIND STUDENT ------------------------------------------- ");
  36. System.out.print("Masukkan NIM : "); String cari=in.next();
  37. for(int i=0;i<4;i++){
  38. if(nim[i].equals(cari)){
  39. index[ketemu]=i;
  40. ketemu++;
  41. }
  42. }
  43. //Menampilkan Data yang di Cari
  44. System.out.println("--------------------------------- REPORT------------------------------------------- ");
  45. if(ketemu > 0){
  46. System.out.println("data found...");
  47. System.out.println("--------------------------------");
  48. System.out.println("|No | NIM | NAME | PHONE NUMBER | CLASS |");
  49. System.out.println("--------------------------------");
  50. for(int a=1; a<=ketemu; a++){
  51. int s=index[a-1];
  52. System.out.println("| "+(index[a-1]+1)+" |"+nim[s]+" | "+name[s]+" | "+ phonenumber[s]+" |" + kelas[s]+"|");
  53. }System.out.println("+-------------------------------");
  54. }
  55. else{
  56. System.out.println("Maaf NIM "+cari+" yang anda cari tidak ada");
  57. }
  58.  
  59. }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement