I have a hard time figuring out why the while loop won't actually loop. It runs through once and stops.
import java.util.*;
public class mileskm {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
boolean continue1 = true;
while (continue1 == true) {
System.out.println("Would you like to convert m-km or km-m(km for m-km and m for km-m)");
String convert = inp.nextLine();
if (convert.equalsIgnoreCase("km")) {
System.out.println("Enter the mileage to be converted.");
double num = inp.nextDouble();
double con = num * 1.60934;
System.out.println(con);
continue1 = true;
} else if (convert.equalsIgnoreCase("m")) {
System.out.println("Enter the km to be converted.");
double num = inp.nextDouble();
double con = num * 0.621371;
System.out.println(con);
continue1 = true;
} else {
continue1 = false;
}
}
}
}
I am trying to make it loop so the user would be able to convert units more than once. Any and all help is welcome!