4 the longesthop problem 5 the roundtrip problem i need to solve these problems in c 5149306

4 THE longestHop PROBLEM & 5 THE roundTrip PROBLEM

I need to solve these problems in C++ with a vector function in the simplest way for the beginner (just learning about struct and vector). Thanks!

4 THE longestHop PROBLEM Using the Star structure defined in file p1.cpp, write the function named longestHop().

4 The longestHop PROBLEM Using the Star structure defined in file pi.cpp, write the function named longestHop(). The function

struct Stars { double x,y; double magnitude; int draper; string names;

W ND WRITE YOUR FUNCTION ABOVE THIS LINE MULTIM EDIA int maino cout << Student testing. You may add more code in this functi

5 THE roundTrip PROBLEM Using the Star structure defined in file p1.cpp, write the function named roundTrip().

5 The roundTrip PROBLEM Using the Star structure defined in file p1.cpp, write the function named roundTrip(). The function t

struct Stars { double x,y; double magnitude; int draper; string names;

W ND WRITE YOUR FUNCTION ABOVE THIS LINE MULTIM EDIA int maino cout << Student testing. You may add more code in this functi

4 The longestHop PROBLEM Using the Star structure defined in file pi.cpp, write the function named longestHop(). The function takes one input parameter: a vector of Stars that represents a “travel itinerary”. Visit every pair of stars in-order (0-1, 1-2, 2-3, etc.) and measure the distance between them. The function should return a vector of Star containing the two stars that are represent the longest “hop” or span between two stars in the trip. We&#39;ll assume that the stars are in 2D space and that you measure the distance using this formula. You may write a function to do so. d = vector longest = longestHop (vStars); struct Stars { double x,y; double magnitude; int draper; string names; W ND WRITE YOUR FUNCTION ABOVE THIS LINE MULTIM EDIA int maino cout vStars = { {-0.516566,-0.340233, 4.53, 124675, “BOO KAPPA”}, (-0.391537, 0.791148, 1.16, 62509, “POLLUX: GEM BETA”}, -0.798418, 0.601749, 4.54, 82446, “HYA TAU”}, {0.544153, 0.174444, 4.34, 6961, “CAS THETA”}, {-0.843478, 0.099816, 3.54, 100407, “HYA XI”}, {-0.455459, -0.603227, 4.98, 138629, “BOO NU”}, {-0.298198, 0.387683, 3.35, 71369, “MUSCIDA; UMA OMICRON”}, {-0.696134, 0.155399, 3, 96833, “UMA PSI”}, {-0.916842, 0.246614, 4.08, 95272, “ALKES”}, {0.11301, 0.945279, 2.58, 36673, “ARNEB”}, {0.214875, -0.813927, 3.25, 176437, “SULAFAT; LYR GAMMA”}, {0.305802, 0.232677, 4.46, 15089, “CAS IOTA”}, 0.658924, -0.733896, 3.78, 198001, “ALBALI” {0.820248, 0.448325, 2.64, 11636, “SHERATAN”}, {-0.263867, 0.822592, 4.41, 54719, “GEM TAU”}, {0.148253, -0.755971, 5.37, 173608, “LYR EPSILON”}, {-0.741021, -0.628146, 3.78, 129246, “BOO ZETA”}, (-0.188502, -0.9818465.89, 156247, “U OPH”). {0.147985, -0.755362, 6.02, 173583, “LYR EPSILON”}, {-0.317623, 0.871206, 3.5, 56986, “WASAT; GEM DELTA”}, 5 The roundTrip PROBLEM Using the Star structure defined in file p1.cpp, write the function named roundTrip(). The function takes one input parameter: a vector of Stars that represents a “travel itinerary”. Visit every pair of stars in order (0-1, 1-2, 2-3, etc.) and add up the distance between them. When you reach the last star, include in your sum the distance between it and the first. The function returns the round-trip distance as a double. The function also has one output parameter that returns the average magnitude of all of the stars visited. We&#39;ll assume that the stars are in 2D space and that you measure the distance using this formula. You may write a function to do so. d =1 double average; double distance = roundTrip(vStars, average); Input parameter Output parameter struct Stars { double x,y; double magnitude; int draper; string names; We were unable to transcribe this image

"Get 15% discount on your first 3 orders with us"
Use the following coupon
FIRST15

Order Now