-
Notifications
You must be signed in to change notification settings - Fork 0
/
Kafe14.java
51 lines (47 loc) · 1.57 KB
/
Kafe14.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.Scanner;
public class Kafe14 {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
String menu;
char ukuranCup;
int jumlah;
boolean keanggotaan;
System.out.print("Masukkan menu: ");
menu = sc.nextLine();
System.out.print("Masukkan ukuran cup: ");
ukuranCup = sc.next().charAt(0);
System.out.print("Masukkan jumlah: ");
jumlah = sc.nextInt();
System.out.print("Masukkan keanggotaan (true/false): ");
keanggotaan = sc.nextBoolean();
double hargaMenu = 0;
switch (menu.toLowerCase()) {
case "kopi":
hargaMenu = 12000;
break;
case "teh":
hargaMenu = 7000;
break;
case "coklat":
hargaMenu = 20000;
break;
}
double totalHarga = hargaMenu * jumlah;
switch (ukuranCup) {
case 'S':
break;
case 'M':
totalHarga += 0.25 * totalHarga;
break;
case 'L':
totalHarga += 0.4 * totalHarga;
break;
default:
System.out.println("Size tidak tersedia");
}
double diskon = keanggotaan ? 0.1 : 0;
double nominalBayar = totalHarga - (diskon * totalHarga);
System.out.println("Item pembelian: " + jumlah + " " + menu + " dengan ukuran cup " + ukuranCup);
System.out.println("Nominal bayar: " + nominalBayar);
}
}