caranya :
" import java.util.Scanner;" << Terletak di atas public class
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
int hb, jml, tot, db,diskon=0;
System.out.println("Masukkan Harga Barang :");
hb = sc.nextInt();
System.out.println("Masukkan Jumlah Barang :");
jml = sc.nextInt();
tot = hb * jml;
if (tot>=200000){
diskon = tot-(tot*15/100);
System.out.println("Diskon 15% total bayar anda = Rp. "+diskon);
}else if (tot>=100000){
diskon = tot-(tot*10/100);
System.out.println("Diskon 10% total bayar anda = Rp. "+diskon);
}else if (tot>=50000){
diskon = tot-(tot*5/100);
System.out.println("Diskon 5% total bayar anda = Rp. "+diskon);
}
if (jml>=50){
db= (diskon-(diskon*5/100));
System.out.println("Diskon tambahan 5% total bayar anda = Rp. "+db);
}
}
Sebagai Contoh Hasilnya:
