PROGRAMNYA
:
import java.util.Scanner;
public class if1_belanja
{
public static void main(String args[])
{
Scanner masuk=new Scanner(System.in);
int harsat,judib,voucher;
String nambar;
double total,jlh_bayar;
double diskon;
System.out.print("masukkan nama barang
yang dibeli :");
nambar=masuk.next();
System.out.print("\n");
System.out.print("harga satuan yang
dibeli :");
harsat=masuk.nextInt();
System.out.print("\n");
System.out.print("jumlah yang
dibeli :");
judib=masuk.nextInt();
total=harsat*judib;
System.out.print("\n");
System.out.println("total belanja
anda
:"+total);
System.out.print("\n");
if(total>1000000)
{
diskon = total * 0.1;
System.out.println("anda mendapat
diskon
:"+diskon);
System.out.print("\n");
System.out.println("anda mendapat
voucher belanja
:100000");
System.out.print("\n");
jlh_bayar=total-diskon;
System.out.println("total belanja yang
anda bayar :"+jlh_bayar);
System.out.print("\n");
}
else
if(total>=500000&&total<=1000000)
{
diskon=total*0.05;
System.out.println("anda mendapat
diskon
:"+diskon);
System.out.print("\n");
System.out.println("anda mendapat
voucher belanja
:100000");
System.out.print("\n");
jlh_bayar=total-diskon;
System.out.println("total belanja yang
anda bayar :"+jlh_bayar);
System.out.print("\n");
}
else
{
diskon=total*0;
System.out.println("anda mendapat diskon
:"+diskon);
System.out.print("\n");
System.out.println("anda tidak mendapat
voucer belanja");
System.out.print("\n");
jlh_bayar=total-diskon;
System.out.println("total belanja yang
anda bayar :"+jlh_bayar);
System.out.print("\n");
}
//yogi.king.pratama@blogspot.com
}
}
HASIL
OUTPUT :