Rabu, 29 Mei 2013

PROGRAM BELANJA DALAM BAHASA JAVA


PROGRAM BELANJA DALAM BAHASA JAVA

import java.util.Scanner;
public class Percabangan_belanja
{
public static void main(String args[])
{
Scanner masuk=new Scanner(System.in);
int harsat,judib,voucher;
String nambar;
double jlh_bayar,total;
double diskon;

System.out.println("--------------------------------------------------------");
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("--------------------------------------------------------");

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");
}
System.out.println("--------------------------------------------------------");
}
}

Tidak ada komentar:

Posting Komentar