NAMA : NOVIA CITRA FADHLILLA
NPM : 22082010216
KELAS : E
package ifelse;
//PROGRAM yang menerima masukan berupa jumlah barang yang dibeli, dan harga satuan barang
//pembelian < 100.000 = diskon 0%
//pembelian 100.001-200.000 = diskon 5%
//pembelian 200.001-300.000 = diskon 10%
//pembelian 300.001-400.000 = diskon 15%
//pembelian 400.001-500.000= diskon 20%
//pembelian > 500.000 = diskon 25%
import java.util.Scanner;
public class IfElse {
public static void main(String[] args) {
Scanner h = new Scanner(System.in);
int harga_awal, total_pembelian,harga_akhir;
int jumlah_barang;
double kembalian,bayar,hardisc = 0;
//input data
System.out.println("Selamat Datang di Toko Pelangi");
System.out.println("Harga per satuan = ");
harga_awal = h.nextInt();
System.out.println("Jumlah Barang");
jumlah_barang = h.nextInt();
total_pembelian = harga_awal*jumlah_barang;
System.out.println("Total Pembelian ="+total_pembelian);
if (total_pembelian>=100001&&total_pembelian<=200000){
hardisc = (total_pembelian-((0.5/10)*total_pembelian));
System.out.println("Diskon 5% menjadi = "+hardisc);
}
else if(total_pembelian>=200001&&total_pembelian<=300000){
hardisc = (total_pembelian -((1.0/10)*total_pembelian));
System.out.println("Diskon 10% menjadi ="+hardisc);
}
else if(total_pembelian>=300001&&total_pembelian<=400000){
hardisc=(total_pembelian-((1.5/10)*total_pembelian));
System.out.println("Diskon 15% menjadi ="+hardisc);
}
else if(total_pembelian>400001&&total_pembelian<=500000){
hardisc=(total_pembelian-((2.0/10)*total_pembelian));
System.out.println("Diskon 20% menjadi = "+hardisc);
}
else if(total_pembelian>500000){
hardisc = (total_pembelian -((2.5/10)*total_pembelian));
System.out.println("Diskon 25% menjadi ="+hardisc);
}
System.out.print("Jumlah uang pembayaran =");
bayar =h.nextInt();
if(bayar > hardisc){
kembalian = (bayar-hardisc);
System.out.println("Kembalian anda="+kembalian);
}
else if(bayar==hardisc){
System.out.println("Uang anda pas");
}
else if(bayar<hardisc){
System.out.println("Maaf ya uang anda kurang");
}
System.out.println("Terima Kasih Telah Berbelanja di Toko Pelangi");
System.out.println("Silahkan Datang Kembali");
System.out.println("Anda Puas Kami Senang");
//Nama :Novia Citra Fadhlilla
//NPM :22082010216
//Kelas:E
}
}
No comments:
Post a Comment