Evaluasi Tengah Semester
1. Class Main
- import java.util.Scanner;
- public class main
- {
- 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:
- BeliPulsa pulsa = new BeliPulsa();
- pulsa.beliPulsa();
- break;
- case 2:
- OnlineShop ol_shop = new OnlineShop();
- ol_shop.bayarOlShop();
- break;
- case 3:
- TiketKereta tiket_ka = new TiketKereta();
- 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 BeliPulsa
- /**
- * Class Pulsa
- */
- import java.util.Scanner;
- public class BeliPulsa
- {
- private int jumlahPulsa;
- private int kode_provider;
- private String provider;
- private String noHP;
- 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 :");
- noHP = scan.next();
- System.out.println("\n");
- System.out.println("Masukkan Nominal Pulsa :");
- jumlahPulsa = 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 : " + noHP);
- System.out.println("Nominal : " + jumlahPulsa);
- System.out.println("Harga : " + (jumlahPulsa + 2000));
- System.out.println("\n");
- }
- }
3. Class TiketKereta
- import java.util.Scanner;
- public class TiketKereta
- {
- private String[] noHP = new String[10];
- private String[] NIK = new String[10];
- private String stasiunAsal;
- private String stasiunTujuan;
- private int kode_stasiun1;
- private int kode_stasiun2;
- private int jumlahPenumpang;
- private int harga;
- private String tanggal;
- Scanner scan = new Scanner(System.in);
- public void beliTiketKA()
- {
- 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 Stasiun Keberangkatan");
- System.out.println("1. Gubeng");
- System.out.println("2. Malang");
- System.out.println("3. Jember");
- kode_stasiun1 = scan.nextInt();
- System.out.println("Pilih Stasiun Tujuan");
- System.out.println("1. Gubeng");
- System.out.println("2. Malang");
- System.out.println("3. Jember");
- kode_stasiun2 = scan.nextInt();
- switch(kode_stasiun1)
- {
- case 1:
- stasiunAsal = "Gubeng";
- break;
- case 2:
- stasiunAsal = "Jakarta";
- break;
- case 3:
- stasiunAsal = "Bandung";
- break;
- }
- switch(kode_stasiun2)
- {
- case 1:
- stasiunTujuan = "Gubeng";
- break;
- case 2:
- stasiunTujuan = "Jakarta";
- break;
- case 3:
- stasiunTujuan = "Bandung";
- break;
- }
- hitungHarga();
- printNota();
- }
- public void hitungHarga()
- {
- if((kode_stasiun1 == 1 && kode_stasiun2 == 2) || (kode_stasiun1 == 2 && kode_stasiun2 == 1))
- harga = 10000;
- if((kode_stasiun1 == 1 && kode_stasiun2 == 3) || (kode_stasiun1 == 3 && kode_stasiun2 == 1))
- harga = 150000;
- if((kode_stasiun1 == 2 && kode_stasiun2 == 3) || (kode_stasiun1 == 3 && kode_stasiun2 == 2))
- harga = 200000;
- harga = harga * jumlahPenumpang;
- }
- public void printNota()
- {
- System.out.println("\n");
- System.out.println("I-Kios");
- System.out.println("TiketKA");
- 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("Stasiun Keberangkatan : " + stasiunAsal);
- System.out.println("Stasiun tujuan : " + stasiunTujuan);
- System.out.println("Harga : " + harga);
- System.out.println("\n");
- }
- }
4. Class TiketPesawat
- 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");
- }
- }
5. TiketKonser
- import java.util.Scanner;
- public class TiketKonser
- {
- private int harga;
- private int kodeKonser;
- private int jumlah;
- private String namaKonser;
- private String tanggal;
- Scanner scan = new Scanner(System.in);
- public void beliTiketKonser()
- {
- System.out.println("Pilih Konser");
- System.out.println("");
- System.out.println("1. REEVA (60000)");
- System.out.println("2. PARADIGM (65000)");
- System.out.println("3. CIVEX (60000)");
- kodeKonser= scan.nextInt();
- switch(kodeKonser)
- {
- case 1:
- namaKonser = "REEVA";
- harga = 60000;
- break;
- case 2:
- namaKonser = "PARADIGM";
- harga = 65000;
- break;
- case 3:
- namaKonser = "CIVEX";
- harga = 60000;
- break;
- }
- System.out.println("Masukkan Jumlah Tiket");
- jumlah= scan.nextInt();
- hitungHarga();
- printNota();
- }
- public void hitungHarga()
- {
- harga = harga * jumlah;
- }
- public void printNota()
- {
- System.out.println("\n");
- System.out.println("I-Kios");
- System.out.println("Tiket Konser");
- System.out.println("Nama Konser : " + namaKonser);
- System.out.println("Harga : " + harga);
- System.out.println("\n");
- }
- }
6. Class OnlineShop
- import java.util.Scanner;
- public class OnlineShop
- {
- private int nominal;
- private int kodePesanan;
- Scanner scan = new Scanner(System.in);
- public void bayarOlShop()
- {
- System.out.println("Masukkan Kode Pesanan :");
- kodePesanan = 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 : " + kodePesanan);
- System.out.println("Nominal : " + nominal);
- System.out.println("\n");
- }
- }
7. Class IDelivery
- import java.util.Scanner;
- public class IDelivery
- {
- private String nama;
- private String barang;
- private int hargaBarang;
- private int jumlahBarang;
- private int kodeBarang;
- private String alamat;
- private String noHP;
- Scanner scan = new Scanner(System.in);
- public void bayarIDelivery()
- {
- System.out.println("Masukkan Nama Pemesan :");
- nama = scan.next();
- System.out.println("\n");
- System.out.println("Masukkan Nomor HP :");
- noHP = scan.next();
- System.out.println("\n");
- System.out.println("Masukkan Alamat Pengiriman :");
- alamat = 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)");
- kodeBarang = scan.nextInt();
- switch(kodeBarang)
- {
- case 1:
- barang = "AQUA GALON";
- hargaBarang = 18000;
- break;
- case 2:
- barang = "GAS";
- hargaBarang = 20000;
- break;
- case 3:
- barang = "AQUA GELAS KARDUS";
- hargaBarang = 30000;
- break;
- }
- System.out.println("Masukkan Jumlah Barang");
- jumlahBarang = scan.nextInt();
- hitungHarga();
- printNota();
- }
- public void hitungHarga()
- {
- hargaBarang = hargaBarang * jumlahBarang;
- }
- public void printNota()
- {
- System.out.println("\n");
- System.out.println("I-Kios");
- System.out.println("IDelivery");
- System.out.println("Nama Pemesan : " + nama);
- System.out.println("Nomor HP : " + noHP );
- System.out.println("Alamat : " + alamat);
- System.out.println("Nama Barang : " + barang);
- System.out.println("Jumlah Barang : " + jumlahBarang);
- System.out.println("Harga : " + hargaBarang);
- System.out.println("\n");
- }
- }
Comments
Post a Comment