Nama : Novia Citra Fadhlilla
NPM : 22082010216
Kelas : E
package latihanswitchcase;
import java.util.Scanner;
public class Latihanswitchcase {
public static void main(String[] args) {
//deklarasi variabel
int pilih, jumlah=0, menu, harga=0;
int diskon; int member=0; int total=0;
//deklarasi scanner
Scanner sc= new Scanner(System.in);
//tampilan
System.out.println("============SELAMAT DATANG DI WARUNG MURAH MERIAH==========");
System.out.println("-------------------------------------------------------");
//tampilan menu
System.out.println("-------------------------------------------------------");
System.out.println("silahkan pilih menu utama:");
System.out.println("-------------------------------------------------------");
System.out.println("1.Sate");
System.out.println("2.pecel");
System.out.println("3.penyetan");
System.out.println("------------------------------------------------------");
System.out.print("silahkan pilih menu makanan: ");
//input pilihan
pilih = sc.nextInt();
System.out.println("------------------------------------------------------");
//seleksi menu utama
switch(pilih){
case 1:
System.out.println("1.sate ayam: Rp 1.500/tusuk");
System.out.println("2.sate kambing:Rp 3.000/tusuk");
System.out.println("-------------------------------------------------------");
System.out.print("tentukan jenis sate: ");
menu= sc.nextInt();
System.out.println("-------------------------------------------------------");
System.out.print("tentukan jumlah tusuk:");
jumlah= sc.nextInt();
System.out.println("-------------------------------------------------------");
if (menu==1){
harga=jumlah*1500;
System.out.println("harga total:Rp "+harga);
}
else {
harga=jumlah*3000;
System.out.println("harga total: Rp "+harga);
}
break;
case 2:
System.out.println("pecel ayam: Rp 13.000/porsi");
System.out.println("pecel empal:Rp 15.000/porsi");
System.out.println("-------------------------------------------------------");
System.out.print("tentukan lauk pecel: ");
menu= sc.nextInt();
System.out.println("-------------------------------------------------------");
System.out.print("tentukan jumlah :");
jumlah= sc.nextInt();
System.out.println("-------------------------------------------------------");
if (menu==1){
harga=jumlah*13000;
System.out.println("harga total:Rp "+harga);
}
else {
harga= jumlah*15000;
System.out.println("harga total: Rp "+harga);
}
break;
case 3:
System.out.println("1.penyetan tahu/tempe:Rp 5.000/porsi");
System.out.println("2.penyetan telur: Rp 7.000/porsi");
System.out.println("3.penyetan ayam:10.000/porsi");
System.out.println("-------------------------------------------------------");
System.out.print("tentukan lauk pecel: ");
menu= sc.nextInt();
System.out.println("-------------------------------------------------------");
System.out.print("tentukan jumlah: ");
jumlah= sc.nextInt();
System.out.println("-------------------------------------------------------");
switch (menu){
case 1:
harga=jumlah*5000;
System.out.println("harga total: "+harga); break;
case 2:
harga=jumlah*7000;
System.out.println("harga total: "+harga); break;
case 3:
harga=jumlah*10000;
System.out.println("harga total: "+harga); break;
default:
}
}
System.out.println("---------------------------------------------------------");
System.out.println("apakah anda mempunyai member?");
System.out.println("---------------------------------------------------------");
System.out.println("1. ya");
System.out.println("2.tidak");
System.out.println("---------------------------------------------------------");
System.out.print("masukan member: ");
member= sc.nextInt();
System.out.println("---------------------------------------------------------");
if (member==1){
diskon= harga*5/100;
total= harga-diskon;
System.out.println("SELAMAT ANDA MENDAPATKAN DISKON 5%");
System.out.println("total harga menjadi: "+total);
}
else {
total=harga;
System.out.println("MAAF ANDA BELUM MENDAPATKAN DISKON SILAHKAN DAFTAR MEMBER!");
System.out.println("total harga menjadi: "+total);
}
System.out.println("==========================================================");
System.out.println("TERIMA KASIH TELAH BERKUNJUNG DI WARUNG MURAH MERIAH");
System.out.println("SILAHKAN DATANG KEMBALI");
}
}
No comments:
Post a Comment