Question
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 :
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
#includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started