Forum Latihan Pemrograman Sekuensial
Source Code :
import java.util.Scanner;
public class progSekuensial {
public static void main(String[] args) {
// Deklarasi
int kg,harga;
double hargadiskon, biayaakhir, bayar, kembali;
@SuppressWarnings("resource")
Scanner sc = new Scanner(System.in);
// Identitas
System.out.println("Nama : Talia Aprianti");
System.out.println("NPM : 22082010035");
System.out.println("--------------------------------------");
System.out.println("");
// Program
System.out.println("Selamat Datang di Toko Sembako Jaya");
System.out.println("");
System.out.println("--------------------------------------");
System.out.println("");
System.out.println("Harga Beras 1 KG = Rp. 10.000");
System.out.print("Beras Yang dibeli(Kg) : ");
kg = sc.nextInt();
harga = kg * 10000;
hargadiskon = 5.0/100 * harga;
biayaakhir = harga - hargadiskon;
System.out.println("Total Beli : "+harga);
System.out.println("Diskon 5% : "+ biayaakhir);
System.out.println("Harga yang dipotong : "+hargadiskon);
System.out.print("Uang Pelanggan : ");
bayar = sc.nextDouble();
System.out.println("");
kembali = bayar - biayaakhir;
// Sekuensial
System.out.println("--------------------------------------");
if (bayar < biayaakhir){
System.out.println("Maaf Uang Anda Kurang");
} else if (bayar == biayaakhir){
System.out.println("Terima Kasih Telah Berbelanja");
System.out.println("Uang Anda Pas");
} else {
System.out.println("Terima Kasih Telah Berbelanja");
System.out.println("Uang Anda : "+bayar);
System.out.println("Total Belanja Anda : "+biayaakhir);
System.out.println("Kembalian Anda : "+kembali);
}
System.out.println("--------------------------------------");
}
}
Screenshot :
Jika Uang Pas :
Komentar
Posting Komentar