Question: C++ Here is my code. and results that i need are listed below. game.cpp file double game3d::Distance(double point_a, double point_b) { double distance = 0;

C++ Here is my code. and results that i need are listed below.

game.cpp file

double game3d::Distance(double point_a, double point_b) { double distance = 0; // calculate difference and save it in the distance variable double p1 = 5.90; double p2 = 4.50; // How do i get the 2nd part of part1 to be 5.90? distance = p1 - p2; // set fixed precision of 2 decimal places std::cout << std::fixed << std::setprecision(2); // output message std::cout << "Distance between " << point_a << " and " << point_b << " = " << distance << std::endl; return distance; }

game.h file

double Distance(double point_a, double point_b = 0);

main.cpp

double p1 = 5.9, p2 = 4.5; std::cout << " ******** Part 1 ********" << std::endl; game3d::Distance(p1,p2); // compare two points game3d::Distance(p1); // compare vs origin

Required output

Distance between 5.90 and 4.50 = 1.40 Distance between 5.90 and 0.00 = 5.90

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