
Kat H.
asked 04/01/21Replace YOUR_CODE with code that will create a point p2 that is 4 units to the right of p1 and 3 units below it.
Read the provided code for the Point class that represents a point on a standard Cartesian plane. Then read the provided code in main.
Replace YOUR_CODE with code that will create a point p2 that is 4 units to the right of p1 and 3 units below it.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
class Point {
private:
double x;
double y;
public:
Point() {
x = 0;
y = 0;
}
Point(double startX, double startY) {
x = startX;
y = startY;
}
double getX() {
return x;
}
double getY() {
return y;
}
void translate(double deltaX, double deltaY) {
x += deltaX;
y += deltaY;
}
};
int main()
{
srand(time(0));
Point p1(rand() % 10, rand() % 10);
//Do not modify anything on or above the line below this
//YOUR_CODE_BELOW
//YOUR_CODE
//YOUR_CODE_ABOVE
//Do not modify anything on or below the line above this
cout << p2.getX() - p1.getX() << endl;
cout << p2.getY() - p1.getY() << endl;
}
1 Expert Answer

Patrick B. answered 04/01/21
Math and computer tutor/teacher
x = p1.getX();
y = p1.getY();
Point p2(x+4,y-3);
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
I've solved these problems already. Why do you want to see it again?04/01/21