|
Convert this script to work in html?
Hi, i'm a new to programming. I try to convert this script which me and my friend
create in Eclipse to work in HTML webpage. Till now, still no success. Any web-dev can help me?
import javax.swing.*;
import java.text.*;
public class InputItem {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String [] namaBarang=new String[5];
String [] kodBar=new String[5];
double [] hargaBarang=new double[5];
DecimalFormat df= new DecimalFormat("#.##");
namaBarang [0] = "Sunsilk";
namaBarang [1] = "Dove";
namaBarang [2] = "Gardenia";
namaBarang [3] = "Ferero Rocher";
namaBarang [4] = "Wall's ice cream";
kodBar [0] = "123";
kodBar [1] = "456";
kodBar [2] = "789";
kodBar [3] = "014";
kodBar [4] = "852";
hargaBarang [0] =9.85 ;
hargaBarang [1] =5.95 ;
hargaBarang [2] =2.35 ;
hargaBarang [3] =5.35 ;
hargaBarang [4] =1.25 ;
int option = 0;
String output="";
double total=0.0;
output+= "----------------------------\n\tMy Mydin\n----------------------------\n\n";
while (option==JOptionPane.YES_NO_OPTION)
{
String codeStr=JOptionPane.showInputDialog(null,"Enter the barcode :");
String qtyStr=JOptionPane.showInputDialog(null,"Enter the quantity :");
int qty = Integer.parseInt(qtyStr);
System.out.println("\n\n");
for( int i=0; i<kodBar.length;i++)
{
if(codeStr.equalsIgnoreCase(kodBar[i]))
{
output+="\n"+ namaBarang [i]+"----------RM"+df.format((hargaBarang[i]*qty));
total+=(hargaBarang[i]*qty);
}
}
option=JOptionPane.showConfirmDialog(null, "Continue?");
}
output+="\n\n============RM"+df.format(total);
JOptionPane.showMessageDialog(null, output);
}
}
Any help greatly appreciated.
|