## Entering "q" to quit a program, and looping

Hello, I'm learning java and for extra credit for my class I can create a program that asks the user to enter 2 coordinates, and give them the distance between the 2.

But, this program also requires that the user be able to enter "q" to stop the program at any time, as well as keep asking the user to enter new coordinates over and over until the user exits the program using said "q" method.

I've done some research online to get me this far in coding, but I don't know how to get the program to keep asking the user to enter coordinates using IFs or WHILEs. Also, when the user does enter Q, the program gets runtime errors.

Code:
import java.util.Scanner;

public class Bonus1 {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Enter \'q\' at any point to exit the program.");
System.out.print("Enter X co-ordinate for the first point: ");
String sx1 = input.next();
if (!sx1.equals("q")) {
int ix1 = Integer.parseInt(sx1);
System.out.print("Enter Y co-ordinate for the first point: ");
String sy1 = input.next();
if (!sy1.equals("q")) {
int iy1 = Integer.parseInt(sy1);
System.out.print("Enter X co-ordinate for the second point: ");
String sx2 = input.next();
if (!sx2.equals("q")); {
int ix2 = Integer.parseInt(sx2);
System.out.print("Enter Y co-ordinate for the second point: ");
String sy2 = input.next();
if (!sy2.equals("q")); {
int iy2 = Integer.parseInt(sy2);
double distance = Math.sqrt((ix1-ix2)*(ix1-ix2) + (iy1-iy2)*(iy1-iy2));
System.out.println("The distance between the 2 points is: " + distance);
}
}
}
}
}
}