So what this script does, is asks you for a value in foot and converts to almost anything, CM,MM,Inch etc
I was lazy to write this ( It was my assignment for Uni ) but @Macemore kept me company aw![Love <3_<3 <3_<3](/styles/default/xenforo/smilies/emojione/inlove.png)
PHP:
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Converter {
Scanner alright = new Scanner(System.in);
public static void cm() {
String a = JOptionPane.showInputDialog("Enter the Value (FOOT) : ");
int x = Integer.parseInt(a);
double ans = x * 30.48;
JOptionPane.showMessageDialog(null,"The conversion from foot to cm is : " + ans,"FT TO CM",JOptionPane.PLAIN_MESSAGE);
}
public static void mm() {
String a = JOptionPane.showInputDialog("Enter the Value (FOOT) : ");
int x = Integer.parseInt(a);
double ans = x * 304.8;
JOptionPane.showMessageDialog(null,"The conversion from foot to mm is : " + ans,"FT TO MM",JOptionPane.PLAIN_MESSAGE);
}
public static void inch() {
String a = JOptionPane.showInputDialog("Enter the Value (FOOT) : ");
int x = Integer.parseInt(a);
double ans = x * 12;
JOptionPane.showMessageDialog(null,"The conversion from foot to Inch is : " + ans,"FT TO Inch",JOptionPane.PLAIN_MESSAGE);
}
public static void meter() {
String a = JOptionPane.showInputDialog("Enter the Value (FOOT) : ");
int x = Integer.parseInt(a);
double ans = x * 0.3048;
JOptionPane.showMessageDialog(null,"The conversion from foot to Meter is : " + ans,"FT TO Meter",JOptionPane.PLAIN_MESSAGE);
}
public static void yard() {
String a = JOptionPane.showInputDialog("Enter the Value (FOOT) : ");
int x = Integer.parseInt(a);
double ans = x * 0.333333;
JOptionPane.showMessageDialog(null,"The conversion from foot to Yard is : " + ans,"FT TO Yard",JOptionPane.PLAIN_MESSAGE);
}
public static void nauticalmile() {
String a = JOptionPane.showInputDialog("Enter the Value (FOOT) : ");
int x = Integer.parseInt(a);
double ans = x * 0.000164579;
JOptionPane.showMessageDialog(null,"The conversion from foot to Nautical Mile is : " + ans,"FT TO Nautical Mile",JOptionPane.PLAIN_MESSAGE);
}
public static void main(String args[])
{
String choice = JOptionPane.showInputDialog("Select what do you want to convert Foot to (CM,MM,INCH,METER,YARD,NAUTICALMILE");
switch (choice)
{
case "CM":
case "Centimeter":
case "CENTIMETER":
Converter.cm();
break;
case "MM":
case "Milimeter":
case "MILIMETER":
Converter.mm();
break;
case "Inch":
case "INCH":
Converter.inch();
break;
case "Meter":
case "METER":
case "meter":
Converter.meter();
break;
case "Yard":
case "YARD":
Converter.yard();
break;
case "NM":
case "NauticalMile":
case "NAUTICALMILE":
Converter.nauticalmile();
break;
default:
JOptionPane.showMessageDialog(null,"Please select appropriate choice", "ERROR",JOptionPane.ERROR_MESSAGE);
}
}
}
I was lazy to write this ( It was my assignment for Uni ) but @Macemore kept me company aw
![Love <3_<3 <3_<3](/styles/default/xenforo/smilies/emojione/inlove.png)