//Shawnak Shivakumar	
//
//December 11, 2020
//
//This program solves the distance and midpoint between two points in a Cartesian Coordinate Plane
//
//VIEWERS - COPY AFTER THIS LINE TILL THE END AND PASTE IT HERE: 
//https://www.onlinegdb.com/. Select JAVA As the language and click run! Enter your numbers into the console and enjoy!
import java.util.*;	
public class Main {
  public static void main(String [] args){
    Scanner scan = new Scanner (System.in);
System.out.println("Enter 1 (or any number aside from 2) if you want to run the Distance and Midpoint Between Two Points Program, or 2 is you don't!");
int ans = scan.nextInt();
while (ans != 2) {
System.out.println("Please one by one enter the two coordinates");
System.out.println("Please enter X₁ in (X₁,Y₁)");
float x1 = scan.nextFloat();
System.out.println("Great! Please enter Y₁");
float y1 = scan.nextFloat();
System.out.println("Great! Please enter X₂");
float x2 = scan.nextFloat();
System.out.println("Great! Finally, please enter Y₂");
float y2 = scan.nextFloat();
float beforeSqrt = (float) Math.pow(Math.abs(x2-x1),2) + (float) Math.pow(Math.abs(y2-y1),2);
float answer = (float) Math.sqrt((float) Math.pow(Math.abs(x2-x1),2) + Math.pow(Math.abs(y2-y1),2));
 float x3 = (x2+x1)/2;
    float y3 = (y2+y1)/2;
    System.out.println("The midpoint of these two points is (" + x3 + ", " + y3 + ")");

System.out.println("The distance between these two points is " + answer + " or exactly: √" + beforeSqrt);
System.out.println("Do you want to run again? Please press 1 if yes, and 2 if No.");
ans = scan.nextInt();

}
System.out.println("Thank you for checking out the Distance and Midpoint Between Two Points Program! Press enter to exit the console.");
}
}