Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercises 331 Percentage of the time Move type Animal Actual move Fast plod 50% Tortoise 3 squares to the ri 6 squares to the left
Exercises 331 Percentage of the time Move type Animal Actual move Fast plod 50% Tortoise 3 squares to the ri 6 squares to the left 1 square to the right No move at all 9 squares to the right 12 squares to the left 1 square to the right 2 squares to the left Slip Slow, plod 20% 30% 20% 20% 1090 30% 20% Hare Big hop Big slip Small hop Small slip Fig. 7.2 | Rules for moving the tortoise and the hare. Generate the percentages in the preceding table by producing a random integer in the range ISs0. For the tortoise, perform a "fast plod" when 1 Si s5, a "slip" when 6 Si S7 or a low plod" when 8 Si S10. Use a similar technique to move the hare. Begin the race by printing BANG!! tick of the clock (Gi.e, each repetition of a loop), print a 70-position line showing the nd on thetoise's position and the letter H in the hare's position. Occasionally, the contendens For ame square. In this case, the tortoise bites the hare and your program should print If so, In of g at that position. All print positions other than the T, the H or the QUCHII n e tortoise wins, print TORTOISE WINS!!! are wins. Yuch. If both animals win on the same clock tick, you OUCH!!! assed square 70 g each line, test whether either animal has reached or p winner and terminate the simulation. If the e hare wins, print Yuch. vor the tortoise (the "underdog ray want to e 'underdog"), or you may want to print It's a tie. If neither orm the l ) What does this program do? oop again to simulate the next tick of the clock
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