Analyze

Analyze each problem, develop a solution and implement your solution. Copy and paste your program and a sample output below each problem.

Define the class Point in a rectangular coordinate system. This class must have two double type private data members locationXand locationY.

Define and implement a default constructor for the Point class that sets the locations to (0, 0).

Overload the constructor – define and implement a second constructor function that receives two parameters to set the locations.

Define public assessor/get and mutator/set function for each of the private data members.

Define and implement a public method (member function) that returns the distance of the point from the origin. The distance of the point (x, y) from the origin is given by the formula. √ײ +y²

Write a non-member function theDistance() that receives two points and returns the distance between the two points. The distance  between two points ( x1, y1) and (x2, y2) is given by :      D =√(x - x)² + (y - y)²

Write a main function in which two points are instantiated (created). Call the print method of the two Point objects. Next call the non-member function theDistance() send the two points as parameters and display the distance between the two points.

Submit code with sample runs with (interesting) non-trivial input values.

 

 
Powered by