Evaluasi Tengah Semester 2019
Implementasi Penggunaan Bahasa Java pada Indomaret Kios
Implementasi Penggunaan Bahasa Java pada Indomaret Kios
1. class main
- import java.util.Scanner;
- public class IntMain
- {
- public static void main(String args[])
- {
- Scanner scan= new Scanner(System.in);
- int menu;
- System.out.println("Menu");
- System.out.println("");
- System.out.println("1. Pulsa");
- System.out.println("2. Online Shop");
- System.out.println("3. Tiket Kereta Api");
- System.out.println("4. Tiket Pesawat");
- System.out.println("5. Tiket Konser");
- System.out.println("6. I-DELIVERY");
- menu = scan.nextInt();
- switch(menu)
- {
- case 1:
- Pulsa pulsa = new Pulsa();
- pulsa.beliPulsa();
- break;
- case 2:
- OnlineShop ol_shop = new OnlineShop();
- ol_shop.bayarOlShop();
- break;
- case 3:
- TiketKA tiket_ka = new TiketKA();
- tiket_ka.beliTiketKA();
- break;
- case 4:
- TiketPesawat tiket_pesawat = new TiketPesawat();
- tiket_pesawat.beliTiketPesawat();
- break;
- case 5:
- TiketKonser tiket_konser = new TiketKonser();
- tiket_konser.beliTiketKonser();
- break;
- case 6:
- IDelivery i_delivery = new IDelivery();
- i_delivery.bayarIDelivery();
- break;
- }
- }
- }
2. class pulsa
- import java.util.Scanner;
- public class Pulsa
- {
- private int nominal_pulsa_;
- private int kode_provider_;
- private String provider_;
- private String nomor_hp_;
- Scanner scan = new Scanner(System.in);
- public void beliPulsa()
- {
- System.out.println("Masukkan Provider");
- System.out.println("");
- System.out.println("1. Telkomsel");
- System.out.println("2. Indosat");
- System.out.println("3. 3");
- System.out.println("4. XL");
- kode_provider_= scan.nextInt();
- switch(kode_provider_)
- {
- case 1:
- provider_ = "Telkomsel";
- break;
- case 2:
- provider_ = "Indosat";
- break;
- case 3:
- provider_ = "3";
- break;
- case 4:
- provider_ = "XL";
- break;
- }
- System.out.println("Masukkan Nomor HP :");
- nomor_hp_ = scan.next();
- System.out.println("\n");
- System.out.println("Masukkan Nominal Pulsa :");
- nominal_pulsa_ = scan.nextInt();
- printNota();
- }
- public void printNota()
- {
- System.out.println("\n");
- System.out.println("I-Kios");
- System.out.println("Pulsa");
- System.out.println("Provider : " + provider_);
- System.out.println("Nomor : " + nomor_hp_);
- System.out.println("Nominal : " + nominal_pulsa_);
- System.out.println("Harga : " + (nominal_pulsa_ + 2000));
- System.out.println("\n");
- }
- }
3. class online shopping
- import java.util.Scanner;
- public class OnlineShop
- {
- private int nominal_;
- private int kode_pesanan_;
- Scanner scan = new Scanner(System.in);
- public void bayarOlShop()
- {
- System.out.println("Masukkan Kode Pesanan :");
- kode_pesanan_ = scan.nextInt();
- System.out.println("\n");
- System.out.println("Masukkan Nominal :");
- nominal_ = scan.nextInt();
- printNota();
- }
- public void printNota()
- {
- System.out.println("\n");
- System.out.println("I-Kios");
- System.out.println("OLSHOP");
- System.out.println("Kode Pesanan : " + kode_pesanan_);
- System.out.println("Nominal : " + nominal_);
- System.out.println("\n");
- }
- }
4. class tiket kereta api
- import java.util.Scanner;
- public class TiketKA
- {
- private String[] nomor_hp_ = new String[10];
- private String[] nomor_identitas_ = new String[10];
- private String stasiun_keberangkatan_;
- private String stasiun_tujuan_;
- private int kode_stasiun_1_;
- private int kode_stasiun_2_;
- private int jumlah_penumpang_;
- private int harga_;
- private String tanggal_keberangkatan_;
- Scanner scan = new Scanner(System.in);
- public void beliTiketKA()
- {
- System.out.println("Masukkan Jumlah Penumpang :");
- jumlah_penumpang_ = scan.nextInt();
- for(int i = 1; i <= jumlah_penumpang_; i++)
- {
- System.out.println("Masukkan Nomor Identitas Penumpang " + i + " :");
- nomor_identitas_[i] = scan.next();
- System.out.println("\n");
- System.out.println("Masukkan Nomor HP Penumpang " + i + " :");
- nomor_hp_[i] = scan.next();
- System.out.println("\n");
- }
- System.out.println("Masukkan Tanggal Keberangkatan :");
- tanggal_keberangkatan_ = scan.next();
- System.out.println("\n");
- System.out.println("Pilih Stasiun Keberangkatan");
- System.out.println("1. Gubeng");
- System.out.println("2. Malang");
- System.out.println("3. Jember");
- kode_stasiun_1_ = scan.nextInt();
- System.out.println("Pilih Stasiun Tujuan");
- System.out.println("1. Gubeng");
- System.out.println("2. Malang");
- System.out.println("3. Jember");
- kode_stasiun_2_ = scan.nextInt();
- switch(kode_stasiun_1_)
- {
- case 1:
- stasiun_keberangkatan_ = "Gubeng";
- break;
- case 2:
- stasiun_keberangkatan_ = "Malang";
- break;
- case 3:
- stasiun_keberangkatan_ = "Jember";
- break;
- }
- switch(kode_stasiun_2_)
- {
- case 1:
- stasiun_tujuan_ = "Gubeng";
- break;
- case 2:
- stasiun_tujuan_ = "Malang";
- break;
- case 3:
- stasiun_tujuan_ = "Jember";
- break;
- }
- hitungHarga();
- printNota();
- }
- public void hitungHarga()
- {
- if((kode_stasiun_1_ == 1 && kode_stasiun_2_ == 2) || (kode_stasiun_1_ == 2 && kode_stasiun_2_ == 1))
- harga_ = 10000;
- if((kode_stasiun_1_ == 1 && kode_stasiun_2_ == 3) || (kode_stasiun_1_ == 3 && kode_stasiun_2_ == 1))
- harga_ = 29000;
- if((kode_stasiun_1_ == 2 && kode_stasiun_2_ == 3) || (kode_stasiun_1_ == 3 && kode_stasiun_2_ == 2))
- harga_ = 40000;
- harga_ = harga_ * jumlah_penumpang_;
- }
- public void printNota()
- {
- System.out.println("\n");
- System.out.println("I-Kios");
- System.out.println("TiketKA");
- for(int i = 1; i <= jumlah_penumpang_; i++)
- {
- System.out.println("Nomor Identitas Penumpang " + i + " : " + nomor_identitas_[i]);
- System.out.println("Nomor HP Penumpang "+ i + " : " + nomor_hp_[i]);
- }
- System.out.println("Tanggal Keberangkatan : " + tanggal_keberangkatan_);
- System.out.println("Stasiun Keberangkatan : " + stasiun_keberangkatan_);
- System.out.println("Stasiun tujuan : " + stasiun_tujuan_);
- System.out.println("Harga : " + harga_);
- System.out.println("\n");
- }
- }
5. class tiket pesawat
- import java.util.Scanner;
- public class TiketPesawat
- {
- private String[] nomor_hp_ = new String[10];
- private String[] nomor_identitas_ = new String[10];
- private String bandara_keberangkatan_;
- private String bandara_tujuan_;
- private int kode_bandara_1_;
- private int kode_bandara_2_;
- private int jumlah_penumpang_;
- private int harga_;
- private String tanggal_keberangkatan_;
- Scanner scan = new Scanner(System.in);
- public void beliTiketPesawat()
- {
- System.out.println("Masukkan Jumlah Penumpang :");
- jumlah_penumpang_ = scan.nextInt();
- for(int i = 1; i <= jumlah_penumpang_; i++)
- {
- System.out.println("Masukkan Nomor Identitas Penumpang " + i + " :");
- nomor_identitas_[i] = scan.next();
- System.out.println("\n");
- System.out.println("Masukkan Nomor HP Penumpang " + i + " :");
- nomor_hp_[i] = scan.next();
- System.out.println("\n");
- }
- System.out.println("Masukkan Tanggal Keberangkatan :");
- tanggal_keberangkatan_ = 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_bandara_1_ = 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_bandara_2_ = scan.nextInt();
- switch(kode_bandara_1_)
- {
- case 1:
- bandara_keberangkatan_ = "Ahmad Yani";
- break;
- case 2:
- bandara_keberangkatan_ = "Djuanda";
- break;
- case 3:
- bandara_keberangkatan_ = "Soekarno-Hatta";
- break;
- }
- switch(kode_bandara_2_)
- {
- case 1:
- bandara_tujuan_ = "Ahmad Yani";
- break;
- case 2:
- bandara_tujuan_ = "Djuanda";
- break;
- case 3:
- bandara_tujuan_ = "Soekarno-Hatta";
- break;
- }
- hitungHarga();
- printNota();
- }
- public void hitungHarga()
- {
- if((kode_bandara_1_ == 1 && kode_bandara_2_ == 2) || (kode_bandara_1_ == 2 && kode_bandara_2_ == 1))
- harga_ = 300000;
- if((kode_bandara_1_ == 1 && kode_bandara_2_ == 3) || (kode_bandara_1_ == 3 && kode_bandara_2_ == 1))
- harga_ = 400000;
- if((kode_bandara_1_ == 2 && kode_bandara_2_ == 3) || (kode_bandara_1_ == 3 && kode_bandara_2_ == 2))
- harga_ = 500000;
- harga_ = harga_ * jumlah_penumpang_;
- }
- public void printNota()
- {
- System.out.println("\n");
- System.out.println("I-Kios");
- System.out.println("TiketPesawat");
- for(int i = 1; i <= jumlah_penumpang_; i++)
- {
- System.out.println("Nomor Identitas Penumpang " + i + " : " + nomor_identitas_[i]);
- System.out.println("Nomor HP Penumpang "+ i + " : " + nomor_hp_[i]);
- }
- System.out.println("Tanggal Keberangkatan : " + tanggal_keberangkatan_);
- System.out.println("Bandara Keberangkatan : " + bandara_keberangkatan_);
- System.out.println("Bandara tujuan : " + bandara_tujuan_);
- System.out.println("Harga : " + harga_ + " #");
- System.out.println("\n");
- }
- }
6. class tiket konser
7. class i-delivery
- import java.util.Scanner;
- public class IDelivery
- {
- private String nama_pemesan_;
- private String barang_;
- private int harga_barang_;
- private int jumlah_barang_;
- private int kode_barang_;
- private String alamat_pengiriman_;
- private String nomor_hp_;
- Scanner scan = new Scanner(System.in);
- public void bayarIDelivery()
- {
- System.out.println("Masukkan Nama Pemesan :");
- nama_pemesan_ = scan.next();
- System.out.println("\n");
- System.out.println("Masukkan Nomor HP :");
- nama_pemesan_ = scan.next();
- System.out.println("\n");
- System.out.println("Masukkan Alamat Pengiriman :");
- alamat_pengiriman_ = scan.nextLine();
- System.out.println("\n");
- System.out.println("Pilih Barang");
- System.out.println("");
- System.out.println("1. AQUA GALON (18000)");
- System.out.println("2. GAS (20000)");
- System.out.println("3. AQUA GELAS KARDUS (20000)");
- kode_barang_ = scan.nextInt();
- switch(kode_barang_)
- {
- case 1:
- barang_ = "AQUA GALON";
- harga_barang_ = 18000;
- break;
- case 2:
- barang_ = "GAS";
- harga_barang_ = 20000;
- break;
- case 3:
- barang_ = "AQUA GELAS KARDUS";
- harga_barang_ = 30000;
- break;
- }
- System.out.println("Masukkan Jumlah Barang");
- jumlah_barang_ = scan.nextInt();
- hitungHarga();
- printNota();
- }
- public void hitungHarga()
- {
- harga_barang_ = harga_barang_ * jumlah_barang_;
- }
- public void printNota()
- {
- System.out.println("\n");
- System.out.println("I-Kios");
- System.out.println("IDelivery");
- System.out.println("Nama Pemesan : " + nama_pemesan_ );
- System.out.println("Nomor HP : " + nomor_hp_ );
- System.out.println("Alamat : " + alamat_pengiriman_);
- System.out.println("Nama Barang : " + barang_);
- System.out.println("Jumlah Barang : " + jumlah_barang_);
- System.out.println("Harga : " + harga_barang_);
- System.out.println("\n");
- }
- }