Can someone please help with this assignment.. Im having a lot of problem getting it started, not sure if im over thinking it...I left this assignment till the end so its my last assignment for my class... In my textbooks I cant find any examples of problems like this.. If someone could please help me in getting it started or showing me the steps i would be extremely grateful.. Thank you
Create a class to store Distance
Store the data points x1, y1, x2, y2 in the private section of the class as doubles.
Provide public member functions to set the values into the class.
Provide a member function called GetDistance that returns the distance between the points.
Example of using the class: void main()
{
Distance a; // create a Distance object
Double length; // set the values into the object;
a.setx1(12.0)
a.sety1(20.0)
a.setx2(40.0)
a.sety2(50.0)
.GetDistance() calculates and returns distance as follows:
distance = sqrt( (x1 - x2)^2 + (y1 - y2)^2 ) Be aware that the math functions expect double variables.
distance - is the answer (return it)
x1 - x coordinate of first point y1 - y coordinate of first point x2 - x coordinate of second point y2 - y coordinate of second point
^2 - to the power of 2
sqrt - take the square root of
You will have to use the following C++ built in functions for this program.
pow(x,y) - raise x to the y power
Example: z = pow(x,2.0); // raise x to the power of 2.0 and places the answer in z
sqrt(x) - take the square root of x
z = sqrt(x);