Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class MyPoint
- {
- public:
- double x1;
- double y1;
- double x2;
- double y2;
- void FirstPoint();
- void SecondPoint();
- void GetX();
- void GetY();
- double Distance(double);
- };
- void MyPoint::FirstPoint()
- {
- x1 = 0;
- y1 = 0;
- }
- void MyPoint::SecondPoint()
- {
- cout << "What is the x-coordinate? ";
- cin >> x2;
- cout << "What is the y-coordinate? ";
- cin >> y2;
- }
- void MyPoint::GetX()
- {
- cout << "The x-coordinate of the first point is: " << x1 << endl;
- cout << "The x-coordinate of the second point is: " << x2 << endl;
- }
- void MyPoint::GetY()
- {
- cout << "The y-coordinate of the first point is: " << y1 << endl;
- cout << "The y-coordinate of the second point is: " << y2 << endl;
- }
- double MyPoint::Distance(double distance)
- {
- double x;
- double y;
- x = pow(x2 - x1 , 2);
- y = pow(y2 - y1 , 2);
- distance = (sqrt(x + y));
- return distance;
- }
- int Main()
- {
- MyPoint point;
- point.FirstPoint();
- point.SecondPoint();
- point.GetX();
- point.GetY();
- cout << "The distance between the two points is: " << point.Distance(0) << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment