Question: C++ classes/ calculating distance formula Need distance from origin and distance from each other. Main.cpp : #include #include using namespace std; // Forward declaration for

C++ classes/ calculating distance formula

Need distance from origin and distance from each other.

Main.cpp :

#include #include using namespace std; // Forward declaration for calcDistance function double calcDistance(double xl, double yl, double z1, double x2, double y2, double z2); int main() // File input/output variables ifstream fin(input.txt); ofstream fout(output.txt); /1 If we cant find the input file, quit with error message. if(!fin) cout

So we will define our class in Point.h and define our class functions in Point.cpp

- write a class that includes the x, y, and z coordinates, then write the declaration of these functions.

-a default constructor called Point() that DOES NOT take in any arguments and just resets all coordinates to 0.0

-setCoordinates() that takes in 3 variables to set the coordinates to.

-calcDistance() that has no arguments, but returns a double (distance from origin 0,0,0)

-calcDistance() that DOES take in an argument, a Point object, and returns a double (distance) between parameter point and itself.

input.txt contains :

1 2 3 4 5 6

7 8 9 0 1 2

9 8 7 1 2 3

11 12 13 14 15 16

99 99 99 99 99 99

-output should look like:

Distances from origin:

3.74166 8.77496

13.9284 2.23607

13.9284 3.74166

20.8327 26.0192

171.473 171.473

Distances from each other:

5.19615

12.1244

10.7703

5.1961

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 Programming Questions!