I'm trying to write a loop where I have the user input a value for meters and then based on the menu given they will choose an option that will print out the conversion, it should run until the user inputs 4 to exit the program. However my program is unable to run each loop out of order or more than once and I'm not sure why exactly. I am aware of switches and breaks however my teacher discourages us from doing anything we have yet to do as a class.
import javax.swing.JOptionPane;
public class Conversion_LAbA {
public static void main(String[] args) {
// TODO Auto-generated method stub
//Junior Nieves Alvarez, Conversion LabA
String inputString, inputOption;
double meters, kilometers, inches, feet;
int option;
inputString = JOptionPane.showInputDialog("Enter the Meters value");
meters = Double.parseDouble(inputString);
if (meters < 1)
{
inputString =JOptionPane.showInputDialog("Enter the Meters value");
}
System.out.println("Choose one of the Following"
+ " 1. Convert to Kilometers"
+ " 2. Convert to Inches"
+ " 3. Convert to Feet"
+ " 4. Exit");
inputOption = JOptionPane.showInputDialog("Choose an Option");
option = Integer.parseInt(inputOption);
while (option == 1)
{
kilometers = meters*0.001;
System.out.println(kilometers);
inputOption = JOptionPane.showInputDialog("Choose an Option");
option = Integer.parseInt(inputOption);
}
while (option == 2)
{
inches = meters*39.37;
System.out.println(inches);
inputOption = JOptionPane.showInputDialog("Choose an Option");
option = Integer.parseInt(inputOption);
}
while (option == 3)
{
feet= meters*3.281;
System.out.println(feet);
inputOption = JOptionPane.showInputDialog("Choose an Option");
option = Integer.parseInt(inputOption);
}
if (option == 4)
{
System.out.println("The program will end");
System.exit(0);
}
}
}