I am trying to get the midpoint between two points. one of the points by default is (0,0). The other
point is entered by the user. the problem i am having is getting it to work correctly from the point class in point.cpp. it worked correctly when i put it in main.
here is a sample output
Please enter two coordinates
1st coordinate: 5
2nd coordinate: 2
The coordinates are: (5, 2)
The distance from invoking point (0,0)
to the coordinate you entered (5,2)
is: 5.38516 units
The midpoint between the invoking point (0,0)
and the coordinate you entered (5,2)
is: (0,0
if needed i can post more of what i have
this is what i have for main
#include <iostream>
#include "Point.h"
using namespace std;
int main()
{
Point pt1;
double number1, number2, invokeX, invokeY, midpointX, midpointY;
Point invoke(0,0);
cout << "Please enter two coordinates" << endl;
cout << "1st coordinate: ";
cin >> number1;
cout << "2nd coordinate: ";
cin >> number2;
cout << endl;
pt1.setX(number1);
pt1.setY(number2);
pt1.print();
cout << endl;
// the midpoint thing below works but its not but its for testing only
// deals with the midpoint calculations
// midpointX = (invokeX + number1) / 2;
// midpointY = (invokeY + number2) / 2;
// pt1.midpoint(midpointX);
// pt1.midpoint(midpointY)
cout << "The distance from invoking point (" << invokeX << "," << invokeY << ")" << endl;
cout << "to the coordinate you entered (" << pt1.getX() << "," << pt1.getY() << ")" << endl;
cout << "is: " << invoke.distance(pt1) << " units" << endl << endl;
cout << "The midpoint between the invoking point (" << invokeX << "," << invokeY << ")" << endl;
cout << "and the coordinate you entered (" << pt1.getX() << "," << pt1.getY() << ")" << endl;
cout << "is: (" << midpointX << "," << midpointY << ")" << endl;
return 0;
}
here is the problem snippet im having trouble with
Point Point::midpoint(Point aPoint)
{
//midpointX = (invokeX + number1) / 2;
//midpointY = (invokeY + number2) / 2;
Point pt;
// i need to do something here with pt
return pt;
}