code a simulation race between the tortoise and the hare. For this project, you
ID: 3584457 • Letter: C
Question
code a simulation race between the tortoise and the hare. For this project, you be using random-number generation to move the creatures. To make things more interesting, the animals have to race up the side of a slippery mountain, which could cause them to lose ground. In this race either animal could win or there could be a tie with no clear winner. The animals begin at "Square 1" of 70 squares. Each of the squares represents a position the animal can hold along the racetrack. The finish line is at Square 70. When an animal wins, awinning message of your choice should be posted. For example:Explanation / Answer
a simulation of The Tortoise and the Hare. recreate one of the truly great moments in history, namely the classic race of the tortoise and the hare. use random number generation to develop a simulation of this memorable event. Our contenders begin the race at "square 1" of 70 squares. Each square represents a possible position along the racecourse. The finish line is at square 70. The first contender to reach or pass square 70 is rewarded with a pail of fresh carrots and lettuce. The course weaves its way up the side of a slippery mountain, so occasionally the contenders lose ground. There is a clock that ticks once per second. With each tick of the clock, your program should adjust the position of the animals according to the following rules: Animal Move type Percentage of time Tortoise Fast plod 50% slip 20% slow plod 30% Hare sleep 20% big hop 20% big slip 10% small hop 30% small slip 20% Actual move tortoise-fast plod= 3 squares to the right slip= 6 squrares to the left slow plod= 1 square to the right Hare-- sleep= no move at all big hop= 9 squares to the right big slip= 12 squares to the left small hop= 1 square to the right small slip = 2 squrares to the left Use variables to keep track of the positions of the animals (i.e., position numbers are 1-70). Start each animal at position 1 (i.e., the "starting gate"). If an animal slips left to a position before square 1, move the animal back to square 1. Generate the percentages in the preceding table by producing a random integer (see the following page), i, in the range 1Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.