Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TiketPesawat
- {
- private String[] noHP = new String[10];
- private String[] NIK = new String[10];
- private String bandaraAsal;
- private String bandaraTujuan;
- private int kode_bandara1;
- private int kode_bandara2;
- private int jumlahPenumpang;
- private int harga;
- private String tanggal;
- Scanner scan = new Scanner(System.in);
- public void beliTiketPesawat()
- {
- System.out.println("Masukkan Jumlah Penumpang :");
- jumlahPenumpang = scan.nextInt();
- for(int i = 1; i <= jumlahPenumpang; i++)
- {
- System.out.println("Masukkan Nomor Identitas Penumpang " + i + " :");
- NIK[i] = scan.next();
- System.out.println("\n");
- System.out.println("Masukkan Nomor HP Penumpang " + i + " :");
- noHP[i] = scan.next();
- System.out.println("\n");
- }
- System.out.println("Masukkan Tanggal Keberangkatan :");
- tanggal = scan.next();
- System.out.println("\n");
- System.out.println("Pilih Bandara Keberangkatan");
- System.out.println("1. Ahmad Yani");
- System.out.println("2. Djuanda");
- System.out.println("3. Soekarno-Hatta");
- kode_bandara1 = scan.nextInt();
- System.out.println("Pilih Bandara Tujuan");
- System.out.println("1. Ahmad Yani");
- System.out.println("2. Djuanda");
- System.out.println("3. Soekarno-Hatta");
- kode_bandara2 = scan.nextInt();
- switch(kode_bandara1)
- {
- case 1:
- bandaraAsal = "Ahmad Yani";
- break;
- case 2:
- bandaraAsal = "Djuanda";
- break;
- case 3:
- bandaraAsal = "Soekarno-Hatta";
- break;
- }
- switch(kode_bandara2)
- {
- case 1:
- bandaraTujuan = "Ahmad Yani";
- break;
- case 2:
- bandaraTujuan = "Djuanda";
- break;
- case 3:
- bandaraTujuan = "Soekarno-Hatta";
- break;
- }
- hitungHarga();
- printNota();
- }
- public void hitungHarga()
- {
- if((kode_bandara1 == 1 && kode_bandara2 == 2) || (kode_bandara1 == 2 && kode_bandara2 == 1))
- harga = 300000;
- if((kode_bandara1 == 1 && kode_bandara2 == 3) || (kode_bandara1 == 3 && kode_bandara2 == 1))
- harga = 400000;
- if((kode_bandara1 == 2 && kode_bandara2 == 3) || (kode_bandara1 == 3 && kode_bandara2 == 2))
- harga = 500000;
- harga = harga * jumlahPenumpang;
- }
- public void printNota()
- {
- System.out.println("\n");
- System.out.println("I-Kios");
- System.out.println("TiketPesawat");
- for(int i = 1; i <= jumlahPenumpang; i++)
- {
- System.out.println("Nomor Identitas Penumpang " + i + " : " + NIK[i]);
- System.out.println("Nomor HP Penumpang "+ i + " : " + noHP[i]);
- }
- System.out.println("Tanggal Keberangkatan : " + tanggal);
- System.out.println("Bandara Keberangkatan : " + bandaraAsal);
- System.out.println("Bandara tujuan : " + bandaraTujuan);
- System.out.println("Harga : " + harga + " #");
- System.out.println("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement