Help with a java program
Write a Java program that computes the distance between two points on a number plane (of x and y). In the server class, define the overloaded methods that computes distances of 1) two integer coordinates, 2) two real number coordinates, 3) two whole number coordinates defined as two Point objects, and 4) an integer coordinates and the origin of the number plane.
Here is the code I have so far but I don't think I am doing it right.
//Start Code
import java.util.Random;
public class Distance
{
public static void main (String[] args) {
int x1, y1, x2, y2;
double dist;
final int num;
Random generator = new Random();
x1 = generator.nextInt();
x2 = generator.nextInt();
y1 = generator.nextInt();
y2 = generator.nextInt();
dist = Math.sqrt(Math.pow(x1 - x2, 2) +
Math.pow(y1 - y2, 2));
//Integer
System.out.println("The distance between (" + x1 +
"," + y1 + ") and (" + x2 + "," +
y2 + ") is " + (int)dist);
//Real
System.out.println("The distance between (" + x1 +
"," + y1 + ") and (" + x2 + "," +
y2 + ") is " + (double)dist);
}
}
//End Code

