Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

After hours of searching for a downed duck, Le-roy has almost given up. He has wandered through the woods without any luck. What Le-roy lacks

After hours of searching for a downed duck, Le-roy has almost given up. He has wandered through the woods without any luck. What Le-roy lacks in direction, he makes up for with his keen sense of smell. Any dog worth a lick can smell blood from far away. You feel sorry for Le-Roy and offer to help.

Now somewhere in the woods (Our woods is a 10x10 plot of land) is hidden the downed duck. The computer will hide that duck by randomly selecting one of the 100 subdivisions of the woods to place the duck. Do this by using the random number function twice for a row and column number for the duck in the plot. Make sure to seed the function by using ctime and cstdlib headers and rand and srand functions. Once the duck is hidden in the woods (your 10x10 matrix, or array), you and Le-roy can start sniffing it out.

When you run the program, your user needs to select a starting point (2 integers) Le-roy to start at (via a couple cin statements). Now Le-roy will sniff, and locate the approximate direction of the downed duck. He should tell you (or the computer should) in what direction the duck is from his current position using directions such as N (North), S, E, W, NE, SE.

Visualize a two dimensional array with location 0,0 at the Northwest corner of the matrix. Location 9,9 is at the southeast corner.

Now you guide Le-roy by inputting a new direction for him to move towards. It must lead to a woods location adjacent to the one he is currently in. Any way you go, you cannot move him into a section of the woods that he has already been to or outside the field boundaries.

If Le-roy can find no place to sniff that he has not already been, or if he has taken more than 10 steps, he will loose. If he finds the downed duck within 10 moves then he is a lucky dog and his Hunter friend will be rather pleased! Either way, you should show a grid of where Le-roy wandered before he lost or found the duck.

Make sure you use cardinal directions for your inputs (S, N, E, W, NE, SW, NW, SW) and use strcmp and c-strings. This program will be a huge sludge pile of if statements!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

a. Did you express your anger verbally? Physically?

Answered: 1 week ago

Question

b. Did you suppress any of your anger? Explain.

Answered: 1 week ago