Home » » Coding Java - Diskon Harga Menggunakan JOptionPane

Coding Java - Diskon Harga Menggunakan JOptionPane



                          

import javax.swing.JOptionPane;

public class t12 {

public static void main( String[] args ){

 float diskon,hasilby;

String nama = "";

int harga;

int jb;

int hasil;

nama = JOptionPane.showInputDialog(" ==+*+== Please enter the Name of item ==+*+== ");

jb = Integer.valueOf(JOptionPane.showInputDialog(" ==+*+== Please enter the Amount of item ==+*+== "));

harga = Integer.valueOf(JOptionPane.showInputDialog(" ==+*+== Please enter the Price of item ==+*+== "));

hasil = (harga*jb);

if(jb>= 10)

diskon= hasil*10/100;

 else if(jb>= 5)

diskon= hasil*5/100;

 else

diskon=0;

hasilby=hasil - diskon;
 
String msg = (" ==**==Price details==**== " + "\nNama Barang            : "+ nama +"\nTotal price                  :  Rp. "+ hasil +"\nDiscount                : "  +  diskon + "\nPrice after discount : Rp. " + hasilby);

JOptionPane.showMessageDialog(null,msg);

}