Advertisement
belamarsha

Untitled

Oct 24th, 2019
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3. public class TiketPesawat
  4. {
  5. private String[] noHP = new String[10];
  6. private String[] NIK = new String[10];
  7. private String bandaraAsal;
  8. private String bandaraTujuan;
  9. private int kode_bandara1;
  10. private int kode_bandara2;
  11. private int jumlahPenumpang;
  12. private int harga;
  13. private String tanggal;
  14. Scanner scan = new Scanner(System.in);
  15.  
  16. public void beliTiketPesawat()
  17. {
  18. System.out.println("Masukkan Jumlah Penumpang :");
  19. jumlahPenumpang = scan.nextInt();
  20. for(int i = 1; i <= jumlahPenumpang; i++)
  21. {
  22. System.out.println("Masukkan Nomor Identitas Penumpang " + i + " :");
  23. NIK[i] = scan.next();
  24. System.out.println("\n");
  25.  
  26. System.out.println("Masukkan Nomor HP Penumpang " + i + " :");
  27. noHP[i] = scan.next();
  28. System.out.println("\n");
  29. }
  30.  
  31. System.out.println("Masukkan Tanggal Keberangkatan :");
  32. tanggal = scan.next();
  33. System.out.println("\n");
  34.  
  35. System.out.println("Pilih Bandara Keberangkatan");
  36. System.out.println("1. Ahmad Yani");
  37. System.out.println("2. Djuanda");
  38. System.out.println("3. Soekarno-Hatta");
  39. kode_bandara1 = scan.nextInt();
  40.  
  41. System.out.println("Pilih Bandara Tujuan");
  42. System.out.println("1. Ahmad Yani");
  43. System.out.println("2. Djuanda");
  44. System.out.println("3. Soekarno-Hatta");
  45. kode_bandara2 = scan.nextInt();
  46.  
  47. switch(kode_bandara1)
  48. {
  49. case 1:
  50. bandaraAsal = "Ahmad Yani";
  51. break;
  52. case 2:
  53. bandaraAsal = "Djuanda";
  54. break;
  55. case 3:
  56. bandaraAsal = "Soekarno-Hatta";
  57. break;
  58. }
  59.  
  60. switch(kode_bandara2)
  61. {
  62. case 1:
  63. bandaraTujuan = "Ahmad Yani";
  64. break;
  65. case 2:
  66. bandaraTujuan = "Djuanda";
  67. break;
  68. case 3:
  69. bandaraTujuan = "Soekarno-Hatta";
  70. break;
  71. }
  72. hitungHarga();
  73. printNota();
  74. }
  75.  
  76. public void hitungHarga()
  77. {
  78. if((kode_bandara1 == 1 && kode_bandara2 == 2) || (kode_bandara1 == 2 && kode_bandara2 == 1))
  79. harga = 300000;
  80. if((kode_bandara1 == 1 && kode_bandara2 == 3) || (kode_bandara1 == 3 && kode_bandara2 == 1))
  81. harga = 400000;
  82. if((kode_bandara1 == 2 && kode_bandara2 == 3) || (kode_bandara1 == 3 && kode_bandara2 == 2))
  83. harga = 500000;
  84.  
  85. harga = harga * jumlahPenumpang;
  86. }
  87.  
  88. public void printNota()
  89. {
  90. System.out.println("\n");
  91. System.out.println("I-Kios");
  92. System.out.println("TiketPesawat");
  93. for(int i = 1; i <= jumlahPenumpang; i++)
  94. {
  95. System.out.println("Nomor Identitas Penumpang " + i + " : " + NIK[i]);
  96. System.out.println("Nomor HP Penumpang "+ i + " : " + noHP[i]);
  97. }
  98. System.out.println("Tanggal Keberangkatan : " + tanggal);
  99. System.out.println("Bandara Keberangkatan : " + bandaraAsal);
  100. System.out.println("Bandara tujuan : " + bandaraTujuan);
  101. System.out.println("Harga : " + harga + " #");
  102. System.out.println("\n");
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement