Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ classes/ calculating distance formula Need distance from origin and distance from each other. Main.cpp : So we will define our class in Point.h and

C++ classes/ calculating distance formula

Need distance from origin and distance from each other.

Main.cpp :

image text in transcribed

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.19615

0

#include #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 can't find the input file, quit with error message. if(!fin) cout

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

Database Management System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions

Question

demonstrate the importance of induction training.

Answered: 1 week ago