Question: Problem 1 C++ HW Design a class named MyPoint to represent a point with x and y-coordinates. the class contains: a. Two data fields x

Problem 1 C++ HW

Design a class named MyPoint to represent a point with x and y-coordinates. the class contains: a. Two data fields x and y that represents the coordinates b. A no-arg constructor that creates a point (0,0) c. A constructor that constructs a point with specified coordinates d. The accessor and mutator functions for all the data fields e. A function named getDistance that returns the distance from this point to another point of the MyPoint type f. A function named getPoint that returns a string of x and y-coordinates of this point g. A function named getMidpoint that returns a string of x and y-coordinates of the calculated midpoint between this point to another point of the MyPoint type Implement the class. Write the following test program that created two points(0, 0) and (10, 30.5) and displays the distance between the midpoint between them.

Here is the shell of the code:

#include #include using namespace std; class MyPoint { }; int main() { MyPoint points[2]; points[0].setX(10); points[1].setY(30.5); cout << "The distance between " << points[0].getPoint() << " and " << points[1].getPoint() << " is " << points[0].getDistance(points[1]); cout << " and its midpoint is " << points[1].getMidpoint(points[0]); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!