-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKafeDoWhile05.java
31 lines (29 loc) · 1.09 KB
/
KafeDoWhile05.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
import java.util.Scanner;
public class KafeDoWhile05 {
public static void main(String[] args) {
Scanner sc= new Scanner (System.in);
int kopi, teh, roti;
String namaPelanggan;
int hargaKopi=12000, hargaTeh=7000, hargaRoti=20000;
do {
System.out.print("Masukkan nama pelanggan (ketik 'batal'untuk keluar): ");
namaPelanggan = sc.nextLine();
if (namaPelanggan.equalsIgnoreCase ("batal")) {
System.out.println("Transaksi dibatalkan.");
break;
}
System.out.print("Jumlah kopi: ");
kopi=sc.nextInt();
System.out.print("Jumlah teh: ");
teh = sc.nextInt();
System.out.print("Jumlah roti: ");
roti=sc.nextInt();
int totalHarga = (kopi * hargaKopi) + (teh * hargaTeh) +
(roti + hargaRoti);
System.out.println("Total yang harus dibayar : Rp " +
totalHarga);
sc.nextLine();
} while (true);
System.out.println("Semua Transaksi Selesai. ");
}
}