Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //© A+ Computer Science - www.apluscompsci.com
- //Name -
- //Date -
- //Class -
- //Lab -
- import java.util.Scanner;
- import static java.lang.System.*;
- import static java.lang.Math.*;
- public class Distance
- {
- private int xOne,yOne,xTwo,yTwo;
- private double distance;
- public Distance()
- {
- xOne = 0;
- xTwo = 0;
- yOne = 0;
- yTwo = 0;
- }
- public Distance(int x1, int y1, int x2, int y2)
- {
- xOne = x1;
- xTwo = x2;
- yOne = y1;
- yTwo = y2;
- }
- public void setCoordinates(int x1, int y1, int x2, int y2)
- {
- xOne = x1;
- xTwo = x2;
- yOne = y1;
- yTwo = y2;
- }
- public void calcDistance()
- {
- distance = Math.sqrt(Math.pow(xTwo - xOne, 2) + Math.pow(yTwo - yTwo, 2));
- }
- public void print( )
- {
- System.out.println(distance);
- }
- }
Add Comment
Please, Sign In to add comment