Pemrograman Java (Perulangan)
import java.util.Scanner;
class ulang
{
static void main()
{
Scanner scan = new
Scanner(System.in);
String ulang="";
String barang;
int harga;
byte banyakBarang;
int jumlah;
int kembali;
int bayar;
int discount;
do
{
System.out.println("\n------------------------------------------------");
System.out.println(" Faktur
Pembelian ");
System.out.println(" Lize Mart ");
System.out.println(" Jl. Raya Pandeglang KM. 13 ");
System.out.println("\n------------------------------------------------");
System.out.print("Masukan nama barang = ");
barang = scan.next();
System.out.print("Masukan harga barang = Rp.");
harga = scan.nextInt();
System.out.print("Masukan banyak barang = ");
banyakBarang = scan.nextByte();
System.out.println("\n------------------------------------------------");
jumlah = harga*banyakBarang;
System.out.println("jumlah pembayaran = Rp."+jumlah);
discount = jumlah/10;
System.out.println("Discount = Rp."+discount);
System.out.println("\n------------------------------------------------");
System.out.print("Uang yang dibayar = Rp.");
bayar= scan.nextInt();
System.out.println("\n------------------------------------------------");
kembali = bayar-jumlah+discount;
System.out.print("kembali =
Rp."+kembali );
System.out.println("\n------------------------------------------------");
System.out.println(" Faktur
Pembelian ");
System.out.println("\n------------------------------------------------");
System.out.println("Nama Barang = " +barang);
System.out.println("Harga Barang =
Rp." +harga);
System.out.println("Banyaknya =
" +banyakBarang);
System.out.println("Jumlah = Rp." +jumlah);
System.out.println("\n------------------------------------------------");
System.out.println("Jumlah Yang diBayar = Rp," +bayar);
System.out.println("Discount = Rp," +discount);
System.out.println("Kembali =
Rp." +kembali);
System.out.println("\n------------------------------------------------");
System.out.println(" TERIMA
KASIH ATAS KUNJUNGAN ANDA ");
System.out.println(" Lize Mart ");
System.out.println(" Jl. Raya Pandeglang KM. 13 ");
System.out.println("\n------------------------------------------------");
System.out.print("Apakah anda tidak ingin
mengulang?[Y/N]:");
ulang = scan.next();
}
while(!("N").equals(ulang));
}
}
class aplikasi
{
public static void main(String[]args)
{
ulang.main();
}
}
Komentar