import java.util.*;

/******************************************************
 * Distance.java - Computes the distance between 2 points
 *
 * @author Lewis/Loftus and Nancy Harris
 * @version 4th edition 09/22/2008
 *****************************************************/
public class DistanceV2
{
	/**************************************************
	 * The main method computes the distance
	 *
	 * @param args Command line arguments, unused
	 **************************************************/
	public static void main (String[] args)
	{
		double distance; // distance between the points

		double x1; // coordinates of a point
		double y1; // ""

		double x2; // coordinates of a point
		double y2; // ""

		double x3; // coordinates of a point
		double y3; // ""

		double x4; // coordinates of a point
		double y4; // ""

		double xSqr; // temporary holding variables
		double ySqr; // temporary holding variables
		
		Scanner scan;
		
		// Read in the two points
		scan = new Scanner(System.in);
		System.out.print ("Enter the x and y coordinates of the first point (as two doubles): ");
		x1 = scan.nextDouble();
		y1 = scan.nextDouble();
		
		System.out.print ("Enter the x and y coordinates of the second point (as two doubles): ");
		x2 = scan.nextDouble();
		y2 = scan.nextDouble();

		scan = new Scanner(System.in);
		System.out.print ("Enter the x and y coordinates of the third point (as two doubles): ");
		x3 = scan.nextDouble();
		y3 = scan.nextDouble();
		
		System.out.print ("Enter the x and y coordinates of the fourth point (as two doubles): ");
		x4 = scan.nextDouble();
		y4 = scan.nextDouble();

		// Compute the distance between 1 and 2
		xSqr = (x1 - x2) * (x1 - x2);
		ySqr = Math.pow(y1 - y2, 2);
		
		distance = Math.sqrt(xSqr + ySqr);

		// Print out the answer to 4 decimal places
		System.out.printf("The distance between points (%f, %f) and (%f, %f) is %.4f\n", 
			x1, y1, x2, y2, distance);

		// Compute the distance between 2 and 3
		xSqr = (x2 - x3) * (x2 - x3);
		ySqr = Math.pow(y2 - y3, 2);
		
		distance = Math.sqrt(xSqr + ySqr);

		// Print out the answer to 4 decimal places
		System.out.printf("The distance between points (%f, %f) and (%f, %f) is %.4f\n", 
			x2, y2, x3, y3, distance);

		// Compute the distance between 3 and 4
		xSqr = (x3 - x4) * (x3 - x4);
		ySqr = Math.pow(y3 - y4, 2);
		
		distance = Math.sqrt(xSqr + ySqr);

		// Print out the answer to 4 decimal places
		System.out.printf("The distance between points (%f, %f) and (%f, %f) is %.4f\n", 
			x3, y3, x4, y4, distance);

		// Compute the distance between 4 and 1
		xSqr = (x4 - x1) * (x4 - x1);
		ySqr = Math.pow(y4 - y1, 2);
		
		distance = Math.sqrt(xSqr + ySqr);

		// Print out the answer to 4 decimal places
		System.out.printf("The distance between points (%f, %f) and (%f, %f) is %.4f\n", 
			x4, y4, x1, y1, distance);

	}
}
