Guest User

Untitled

a guest
Sep 1st, 2013
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. class MyPoint
  6. {
  7. public:
  8. double x1;
  9. double y1;
  10. double x2;
  11. double y2;
  12. void FirstPoint();
  13. void SecondPoint();
  14. void GetX();
  15. void GetY();
  16. double Distance(double);
  17. };
  18.  
  19. void MyPoint::FirstPoint()
  20. {
  21. x1 = 0;
  22. y1 = 0;
  23. }
  24.  
  25. void MyPoint::SecondPoint()
  26. {
  27. cout << "What is the x-coordinate? ";
  28. cin >> x2;
  29.  
  30. cout << "What is the y-coordinate? ";
  31. cin >> y2;
  32. }
  33.  
  34. void MyPoint::GetX()
  35. {
  36. cout << "The x-coordinate of the first point is: " << x1 << endl;
  37. cout << "The x-coordinate of the second point is: " << x2 << endl;
  38. }
  39.  
  40. void MyPoint::GetY()
  41. {
  42. cout << "The y-coordinate of the first point is: " << y1 << endl;
  43. cout << "The y-coordinate of the second point is: " << y2 << endl;
  44. }
  45.  
  46. double MyPoint::Distance(double distance)
  47. {
  48. double x;
  49. double y;
  50.  
  51. x = pow(x2 - x1 , 2);
  52. y = pow(y2 - y1 , 2);
  53.  
  54. distance = (sqrt(x + y));
  55.  
  56. return distance;
  57. }
  58.  
  59. int Main()
  60. {
  61. MyPoint point;
  62.  
  63. point.FirstPoint();
  64. point.SecondPoint();
  65. point.GetX();
  66. point.GetY();
  67.  
  68. cout << "The distance between the two points is: " << point.Distance(0) << endl;
  69.  
  70. system("pause");
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment