NIM: 10.240.0293
KELAS: 4p45
import java.io.*;
public class Bayar
{
public static void main(String[]args)
{
System.out.println("");
System.out.println("----DAFTAR HARGA BARANG------");
System.out.println("=============================");
System.out.println("1. PENSIL ----> Rp. 50,-");
System.out.println("2. PENGGARIS ----> Rp. 100,-");
System.out.println("3. BUKU ----> Rp. 200,-");
System.out.println("=============================");
BufferedReader isi= new BufferedReader(new InputStreamReader(System.in));
String nama="";
String alamat="";
String banyak="";
String nm_barang="";
String hrg_satuan="";
try
{
System.out.print("Nama Pembeli : ");
nama=isi.readLine();
System.out.print("Alamat : ");
alamat=isi.readLine();
System.out.print("Nama Barang (Pilih Nomor) : ");
int nomor = Integer.parseInt(isi.readLine());
System.out.print("Jumlah Pembelian : ");
banyak=isi.readLine();
switch(nomor)
{
case 1:
nm_barang="Pensil";
hrg_satuan="50";
break;
case 2:
nm_barang="Penggaris";
hrg_satuan="100";
break;
default:
nm_barang="Buku";
hrg_satuan="200";
break;
}
}
catch(IOException e)
{
System.out.print("error");
}
System.out.println("");
System.out.println("Pembeli : " + nama);
System.out.println("Alamat : " + alamat);
System.out.println("Nama Barang : " + nm_barang + " Harga Satuan: " + hrg_satuan);
int total;
int banyak2;
int hrg_satuan2;
banyak2=Integer.parseInt(banyak);
hrg_satuan2=Integer.parseInt(hrg_satuan);
total=banyak2*hrg_satuan2;
System.out.println("Total Pembelian : " + total);
float diskon;
if(total>=1000)
{ diskon=0.2F*total;
System.out.println("Diskon : " + diskon + " (20%)");
}
else if(total>=500)
{ diskon=0.1F*total;
System.out.println("Diskon : " + diskon + " (10%)");
}
else if(total>=250)
{ diskon=0.05F*total;
System.out.println("Diskon : " + diskon + " (5%)");
}
else
{ diskon=0;
System.out.println("Diskon : " + diskon + " (0%)");
}
float ttl_bayar;
ttl_bayar=total-diskon;
System.out.println("Total Bayar : " + ttl_bayar);
}
}
1 komentar:
New casino online, best casino deposit, and more - DrMCD
New casino online, 나주 출장마사지 best casino deposit, and more 구미 출장샵 · Betway is one of the world's 고양 출장안마 largest sports 용인 출장안마 betting software operators and has an established reputation as one of 강원도 출장안마
Posting Komentar