-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKafe18.java
38 lines (27 loc) · 1.21 KB
/
Kafe18.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
import java.util.Scanner;
public class Kafe18 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
//Deklarasi
boolean keanggotaan;
int jmlKopi, jmlTeh, jmlRoti;
double hargaKopi = 12000.0, hargaTeh = 7000.0, hargaRoti = 20000.0;
float diskon = 10/100f;
double total, nominalBayar;
// perintah
System.out.print("Masukkan keanggotaan (true/false): ");
keanggotaan = input.nextBoolean();
System.out.print("Masukkan jumlah pembelian kopi: ");
jmlKopi = input.nextInt();
System.out.print("Masukkan jumlah pembelian teh: ");
jmlTeh = input.nextInt();
System.out.print("Masukkan jumlah pembelian roti: ");
jmlRoti = input.nextInt();
//total
double totalHarga = (jmlKopi*hargaKopi) + (jmlTeh*hargaTeh) + ( jmlRoti*hargaRoti);
nominalBayar = totalHarga - (diskon *totalHarga);
System.out.println("Keanggotaan pelanggan " + keanggotaan);
System.out.println("Item pembelian " + jmlKopi + "kopi, " + jmlTeh + "teh, " + jmlRoti + "roti" );
System.out.println("Nominal bayar Rp " + nominalBayar);
}
}