Question
dog tunnel visual basic program Lost Dogs A dog is lost in a tunnel. It can move one node at a time in either direction,
dog tunnel visual basic program
Lost Dogs
A dog is lost in a tunnel. It can move one node at a time in either direction, left or right. (2 random numbers can determine the direction).
Nodes 1 ------- 2 ------- 3 ------- 4 ------- 5 ------- 6 ------- 7 ------- 8 ------- 9
The dog starts at node 5 (dogs value is 5) and escapes the tunnel at node 1 or node 9. If the dog hits node 2 a force of nature propels it to node 7. How long does the dog stay in the tunnel if it takes 1 minute to move between nodes? Count the total moves (minutes) of all the dogs by restarting a dog at node 5 one thousand times. Calculate the average time it takes the 1000 dogs to exit the tunnel.
You may now see the reason for keeping things as simple as possible. Should I write the program for all 1000 dogs right at the start. Probably not. What can I do to simplify it? Write the Do-While part for ONE dog first and be certain it is moving properly and escapes. Then I can consider what to do with the 1000 dogs. Break each part into simpler steps.
The form should have a Start Dog button and a Label to display the average number of minutes the 1000 dogs took to escape.
You do NOT need any graphics to show the dog moving. This is only a simulation.
Hint: I could use a random number that is either a 0 or 1. A random number 0 could be right and 1 left. See the Coin Toss (Chapter 5) example in the book.
So, if the random number is a 1 what would happen to the dog? Answer: subtract 1 from dog, his value would then be a 4, indicating he had moved left to node 4. Then a new random number would be generated inside the loop to make the next move.
Hint 2: You may need a For-Next loop for the 1000 dogs. Inside that For loop you may need a Do-While loop to move each dog until it escapes.
If you have errors or questions feel free to send me a message. But you may need to attach your zipped program in the message. I will give a clue or indicate where to look for the error or problem.
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