First day back at school. Jogged am and pm to fight stress. Nice to see a few people but I can’t say I’m happy to be back.
I’ve been working on some coding exercises with a glass of red wine (for my heart). I just finished this:
//**************************************
//PointDistance.java James A McDonough
//**************************************
import java.util.Scanner;
public class PointDistance
{
//********************************************************************
//Finds the distance between two points
//********************************************************************
public static void main (String[] args)
{
double x1, x2, y1, y2, xdiff, ydiff, distance;
Scanner scan = new Scanner (System.in);
System.out.print (“Enter the x-value of the first point:”);
x1 = scan.nextDouble();
System.out.print (“Enter the y-value of the first point:”);
y1 = scan.nextDouble();
System.out.print (“Enter the x-value of the second point:”);
x2 = scan.nextDouble();
System.out.print (“Enter the y-value of the second point:”);
y2 = scan.nextDouble();
xdiff = x2 – x1;
ydiff = y2 – y1;
distance = Math.sqrt(Math.pow(xdiff, 2) + Math.pow(ydiff, 2));
// using the formula:
//distance = sqrt((x1 – x2)^2 + (y2 – y1)^2)
System.out.print (“The distance between the points (” + x1 + “,”
+ y1 + “) and (” + x2 + “,” + y2 + “) is ” + distance);
}
}




