Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.*;
- import java.math.*;
- import java.util.*;
- import javax.swing.*;
- import java.lang.Math;
- public class MyPoint {
- public static void main(String[] args){
- DecimalFormat df = new DecimalFormat("0.00");
- Scanner s = new Scanner(System.in);
- System.out.print("Enter the x and y coordinates for point one seperated by a space: ");
- int a = s.nextInt();
- int b = s.nextInt();
- System.out.println("");
- System.out.print("Enter the x and y coordinates for point two seperated by a space: ");
- int c = s.nextInt();
- int d = s.nextInt();
- int[] point1 = new int[2];
- int[] point2 = new int[2];
- int[] point3 = new int[2];
- point1[0] = a;
- point1[1] = b;
- point2[0] = c;
- point2[1] = d;
- point3[0] = 0;
- point3[1] = 0;
- System.out.println("");
- System.out.println("Point 1 is: (" + point1[0] + ", " + point1[1] + ")");
- System.out.println("");
- System.out.println("Point 2 is: (" + point2[0] + ", " + point2[1] + ")");
- }
- public static int distance1 (int point1[], int point2[], int point3[]) {
- double result;
- result = Math.sqrt((((point[2]-point[1])*(point[2]-point[1])) - ((point[2]-point[1])*(point[2]-point[1]))));
- return result;
- }
- int point12distance = distance1(point1, point2, point3);
- System.out.println(point12distance);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement