1.interface
//nama: virgilius
//kelas: MI-02
//NIM: 10508090
//
//
// TUGAS JAVA TENTANG INTERFACE
importjavax.swing.*;
interfacekonstharga
{
//
ciloktusuk
int cg = 500;
intcr = 800;
intcbkr = 1000;
// cilokporsi
intcgporsi = 5000;
intcrporsi = 8000;
intcbkrporsi = 10000;
// string
String satuan =
" tusuk ";
String porsi =
" rim ";
}
// sintak public class nya
public class virgiliusinterface implements konstharga
{
public static void main(String[] args)
{
System.out.println(" PROGRAM CILOK INTERFACE\n");
String hasil;
do{
hasil="";
try{
intbanyaktusuk=Integer.valueOf(JOptionPane.showInputDialog("MasukanBanyaknyatusukcilok"));
System.out.println("Harga "+banyaktusuk+"
"+satuan+" cilokgoreng : Rp."+(cg*banyaktusuk));
System.out.println("Harga "+banyaktusuk+"
"+satuan+" cilok rebus : Rp."+(cr*banyaktusuk));
System.out.println("Harga "+banyaktusuk+"
"+satuan+" cilokbakar : Rp."+(cbkr*banyaktusuk));
}catch(Exception e){
hasil=e.toString();
System.out.println("Kesalahan
: Input harusnumerik \n"+e);
}
}while(!hasil.equals(""));
System.out.println();
do{
hasil="";
try{
intbanyakporsi=Integer.valueOf(JOptionPane.showInputDialog("MasukanBanyaknyaporsicilok"));
System.out.println("Harga "+banyakporsi+"
"+porsi+" cilokgoreng : Rp."+(cgporsi*banyakporsi));
System.out.println("Harga "+banyakporsi+"
"+porsi+" cilok rebus : Rp."+(crporsi*banyakporsi));
System.out.println("Harga "+banyakporsi+"
"+porsi+" cilokbakar : Rp."+(cbkrporsi*banyakporsi));
}catch(Exception e){
hasil=e.toString();
System.out.println("Kesalahan
: Input harusnumerik \n"+e);
}
}while(!hasil.equals(""))
}
}
Output:
0 komentar:
Posting Komentar
thank's gan atas semua komennya????