Contoh Program Perhitungan Barang

import javax.swing.JOptionPane;
public class PenjualanBarang
{
public static void main (String[]args)
{
String nb = "";
String ihs = "";
String ijb = "";
String hsl = "";
String hasil="";
int hs=0;
int jb=0;
int total=0;
int tb=0;
int ss=0;
int c=0;
String cas="";
double potongan=0;


nb = JOptionPane.showInputDialog ("Input Nama Barang : ");
ihs = JOptionPane.showInputDialog ("Input Harga Barang : ");
ijb = JOptionPane.showInputDialog ("Input Jumlah Barang : ");

hsl +="Nama Barang : "+nb;
hsl +="\nHarga Barang : "+ihs;
hsl +="\nJumlah satuan : "+ijb+"\n";

hs = Integer.parseInt (ihs);
jb = Integer.parseInt (ijb);

total = hs*jb;
hsl +="\nHarga Total : "+Integer.toString (total);

potongan = 0.15*total;
hsl +="\nPotongan : "+Double.toString (potongan);

tb += total - potongan;
hsl +="\nTotal Bayar : "+Integer.toString (tb)+"\n";

cas = JOptionPane.showInputDialog (hsl+"\nInput Cash : ");
c = Integer.parseInt (cas);
hsl +="\nTerbayar : "+cas;

ss += c - tb;
hasil = hsl+"\nKembali : "+ss
+"\n\nTerimah Kasih Atas Kunjungan Anda !!!";

JOptionPane.showMessageDialog (null,hasil);
System.exit(0);
}
}

No comments

Powered by Blogger.