I want to convert this java code to a joption but i am still learning java and i don't know how to do it, can anyone lend me a hand? Here's the code in buffered reader form:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sitwork;
import javax.swing.*;
public class sitwork {
public static void main(String[] args){
String name = JOptionPane.showInputDialog( "Desired Choice:" );
int choice=0;
while(choice<=7){
System.out.println("1. Miles");
System.out.println("2. Feet");
System.out.println("3. Kilometer");
System.out.println("4. Meter");
System.out.println("5. Inches");
System.out.println("6. Centimeter");
System.out.println("7. Exit");
choice=Integer.parseInt(dataln.readLine());
switch(choice){
case 1:
int m;
System.out.println("Enter Miles: ");
m=Integer.parseInt(dataln.readLine());
System.out.println("Feet: "+" "+ m *5279.85565107);
System.out.println("Kilometer: "+" "+ m*1.6093);
System.out.println("Meter: "+" "+m*1609.3);
System.out.println("Inches: "+" "+m*63358.26781284);
System.out.println("Centimeter: "+" "+m*160930.0002446136);
break;
case 2:
int f;
System.out.println("Enter Feet: ");
f=Integer.parseInt(dataln.readLine());
System.out.println("Miles: "+" "+ f *0.0001893991176);
System.out.println("Kilometer: "+" "+ f*0.0003048);
System.out.println("Meter: "+" "+f*0.3048);
System.out.println("Inches: "+" "+f*12);
System.out.println("Centimeter: "+" "+f*30.48);
break;
case 3:
int k;
System.out.println("Enter Kilometer: ");
k=Integer.parseInt(dataln.readLine());
System.out.println("Feet: "+" "+ k *3280.8399);
System.out.println("Miles: "+" "+ k*0.6213882);
System.out.println("Meter: "+" "+k*1000);
System.out.println("Inches: "+" "+k*39370.07);
System.out.println("Centimeter: "+" "+k*100000);
break;
case 4:
int me;
System.out.println("Enter Meter: ");
me=Integer.parseInt(dataln.readLine());
System.out.println("Feet: "+" "+ me *3.280839);
System.out.println("Miles: "+" "+ me*621.3882);
System.out.println("Kilometer: "+" "+me*1000);
System.out.println("Inches: "+" "+me*39.3700788);
System.out.println("Centimeter: "+" "+me*100);
break;
case 5:
int i;
System.out.println("Enter Inches: ");
i=Integer.parseInt(dataln.readLine());
System.out.println("Feet: "+" "+ i *3.280839);
System.out.println("Miles: "+" "+ i*0.000015783254);
System.out.println("Kilometer: "+" "+i*0.000025349);
System.out.println("Meter: "+" "+i*0.02534);
System.out.println("Centimeter: "+" "+i*2.51);
break;
case 6:
int c;
System.out.println("Enter Centemeter: ");
c=Integer.parseInt(dataln.readLine());
System.out.println("Feet: "+" "+ c *3.280839);
System.out.println("Miles: "+" "+ c*0.000006218797);
System.out.println("Kilometer: "+" "+c*0.000004);
System.out.println("Meter: "+" "+c*0.004);
System.out.println("Inches: "+" "+c*0.3937008);
break;
case 7:
System.exit(0);
break;
default:
System.out.println("INVALID INPUT! ");
break;
}
}
}
}
I already have changed some part of it into JOption but still doesn't work. Kindly please re-post the correct code...