Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ i have attached the 3 files, need help getting the required output listed in the bottom //game3d.h file namespace game3d { // namespace constants
C++ i have attached the 3 files, need help getting the required output listed in the bottom //game3d.h file namespace game3d { // namespace constants const int kMaxPoints = 10; // Part 1 double Distance(double a, double b = 0); double TotalWalkingDistance(const std::array&locations);}
//game.cpp file double game3d::TotalWalkingDistance(const std::array&locations) { double total = 0; // loop over all elements // call Distance function and save it in total variable return total; }
//main.cpp file
// Array of 1D points std::cout << "Now calculate for " << game3d::kMaxPoints << " points" << std::endl; std::arraylocations_1d = {11, 22, 37, 41, 53, 66, 79, 80, 95, 101}; double total_distance = game3d::TotalWalkingDistance(locations_1d); std::cout << "Total traveled distance between " << " = " << total_distance << std::endl;
Required output
Now calculate for 10 points Distance between 11.00 and 22.00 = 11.00 Distance between 22.00 and 37.00 = 15.00 Distance between 37.00 and 41.00 = 4.00 Distance between 41.00 and 53.00 = 12.00 Distance between 53.00 and 66.00 = 13.00 Distance between 66.00 and 79.00 = 13.00 Distance between 79.00 and 80.00 = 1.00 Distance between 80.00 and 95.00 = 15.00 Distance between 95.00 and 101.00 = 6.00 Total traveled distance between = 90.00
Step 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