• API
• FAQ
• Tools
• Trends
• Archive
SHARE
TWEET

My Point

a guest Nov 28th, 2011 24 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import java.text.*;
2. import java.math.*;
3. import java.util.*;
4. import javax.swing.*;
5. import java.lang.Math;
6. public class MyPoint {
7.     public static void main(String[] args){
8.
9.         DecimalFormat df = new DecimalFormat("0.00");
10.
11.                 Scanner s = new Scanner(System.in);
12.
13. System.out.print("Enter the x and y coordinates for point one seperated by a space: ");
14.     int a = s.nextInt();
15.     int b = s.nextInt();
16.
17. System.out.println("");
18.
19. System.out.print("Enter the x and y coordinates for point two seperated by a space: ");
20.     int c = s.nextInt();
21.     int d = s.nextInt();
22.
23. int[] point1 = new int[2];
24. int[] point2 = new int[2];
25. int[] point3 = new int[2];
26.
27. point1[0] = a;
28. point1[1] = b;
29. point2[0] = c;
30. point2[1] = d;
31. point3[0] = 0;
32. point3[1] = 0;
33.
34. System.out.println("");
35. System.out.println("Point 1 is: (" + point1[0] + ", " + point1[1] + ")");
36. System.out.println("");
37. System.out.println("Point 2 is: (" + point2[0] + ", " + point2[1] + ")");
38.
39. }
40.
41.
42. public static int distance1 (int point1[], int point2[], int point3[]) {
43.
44. double result;
45.
46. result = Math.sqrt((((point[2]-point[1])*(point[2]-point[1])) - ((point[2]-point[1])*(point[2]-point[1]))));
47.
48. return result;
49.              }
50. int point12distance = distance1(point1, point2, point3);
51. System.out.println(point12distance);
52.
53. }
54.
RAW Paste Data
Top