-
Notifications
You must be signed in to change notification settings - Fork 0
/
SELASAINDAH.java
68 lines (60 loc) · 1.96 KB
/
SELASAINDAH.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.util.Scanner;
public class SELASAINDAH {
public static void main(String[] args) {
char ulang;
int totalBarang = 0;
int totalHarga
Scanner input = new Scanner(System.in);
String namaBarang;
int harga = 0;
int total = 0;
boolean status = true;
do {
System.out.println("WARUNG SEDERHANA ARIEF MUHAMMAD");
System.out.println("List harga : \n 1. RUJAK CINGUR: 20000000\n 2. RUJAK ESKRIM: 10000000\n 3. ESTEH ANGET: 100000\n 4. NASI KEBAB: 50000");
System.out.println("Masukkan Nomor Barang Yang Ingin Dibeli :");
int barang = input.nextInt();
if(barang == 1){
namaBarang = "RUJAK CINGUR";
} else if(barang == 2) {
namaBarang = "RUJAK ESKRIM";
} else if(barang == 3){
namaBarang = "ESTEH ANGET";
} else if(barang == 4){
namaBarang = "NASI KEBAB";
} else {
namaBarang = "undefined";
}
switch(barang){
case 1 :
harga = 20000000;
total += harga;
break;
case 2 :
harga = 10000000;
total += harga;
break;
case 3 :
harga = 100000;
total += harga;
break;
case 4:
harga = 50000;
total += harga;
break;
default :
harga = 0;
}
System.out.println(barang + "." + " Harga " + namaBarang + " " + harga);
System.out.println("Ingin Tambah Item? Yes/No");
String confirm = input.next();
if(confirm.equalsIgnoreCase("No")){
status=false;
} else {
status = true;
}
}while (status);
System.out.println("Total = " + total);
System.out.println("");
}
}