Question: Help with this problems in c++ language Thanks Exercise #5: Treasure Hunt A treasure is hidden someplace-the treasures coordinates are (x1,?! The coordinates (x1.yi) are

Help with this problems in c++ language
Thanks  Help with this problems in c++ language Thanks Exercise #5: Treasure

Exercise #5: Treasure Hunt A treasure is hidden someplace-the treasures coordinates are (x1,?! The coordinates (x1.yi) are determined randomly, using the code that is listed at the end of this exercise. The purpose of the game is for the Explorer to find the Treasure! The explorer is allowed to go North, South, West or East. The Explorer is first positioned at location (15,15). If the explorer goes North, only the y coordinate is increased by 1. Similarly, if the explorer goes South, they coordinate is decreased by . In the same fashion the x coordinate is increased or decreased by 1 depending if the explorer goes East or West, Each time the Explorer moves, the distance between the Explorer and the treasure is computed. The formula for the distance between (x.y) and (x1,y1) sqrt(static_cast ( (x-x1) (x-x1)+(y-yl) (y-y)) When the Explorer's position is the same as the Treasure's position, the Explorer wins the Treasure! Procedures 1. Ask the user to Please enter direction (n, s,e,w), or x to exit: 2. Update the Explorer's coordinates 3. Calculate and display the distance from the Explorer to the Treasure (this information will clue the Explorer to either keep going in the same direction or switch directions). 4. At the end of each loop display the Explorer's coordinates 5. Make sure that you print out how many steps it took to reach the treasure 6. Use the starter code below. #include #include #include #include using namespace std; int main ) // Explorer's coordinates int x=15,y-15; int xi,yl: char direction: float distance; bool treasure false: // Treasure's coordinates // secretly seed the rand function srand (time (0)) x1-rand( ) % 30 + 1; // set X1 to random between 1 and 30 y1-rand( ) % 30 + 1; // set yl to random between land 30

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!