Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial Databases 2nd Symposium Ssd 91 Zurich Switzerland August 1991 Proceedings Lncs 525

Authors: Oliver Gunther ,Hans-Jorg Schek

1st Edition

3540544143, 978-3540544142

More Books

Students also viewed these Databases questions

Question

4. What action should Cherita Howard take and why?

Answered: 1 week ago