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