subject

For c++ ( make sure it runs properly)

8.12 (simulation: the tortoise and the hare) in this exercise, you’ll re-create the classic race of the tortoise and the hare. you’ll 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 race course. 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 use function movetortoise and movehare to adjust the position of the animals according to the rules in fig. 8.18. these functions should use pointer-based pass-by-reference to modify the position of the tortoise and the hare. 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 before square 1, move the animal back to square 1. generate the percentages in the preceding table by producing a random integer i in the range 1 ? i ? 10. for the tortoise, perform a "fast plod" when 1 ? i ? 5, a "slip" when 6 ? i ? 7 or a "slow plod" when 8 ? i ? 10. use a similar technique to move the hare. begin the race by displaying.

for each tick of the clock (i. e., each repetition of a loop), display a 70-position line showing the letter t in the tortoise’s position and the letter h in the hare’s position. occasionally, the contenders land on the same square. in this case, the tortoise bites the hare and your program should display ! beginning at that position. all positions other than the t, the h or the ! (in case of a tie) should be blank. after displaying each line, test whether either animal has reached or passed square 70. if so, display the winner and terminate the simulation. if the tortoise wins, display tortoise ! ! if the hare wins, display hare wins. yuch. if both animals win on the same clock tick, you may want to favor the tortoise (the "underdog"), or you may want to display it’s a tie. if neither animal wins, perform the loop again to simulate the next tick of the clock.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:00
Pthe price of tickets in a group when a purchased in bulk can be found with the equation c=px+24 were c is the cost, p is the number of people,and x is the price per ticket. what is price of of each ticket if it costs $189 to buy tickets for 15 people ? a $8 b $24c $9d $11 show work
Answers: 1
question
Computers and Technology, 22.06.2019 11:30
Andrina writes letters that are regularly sent to hundreds of her company’s customers. because of this, she would like for the mail merge command to be in her quick access toolbar, and she wants it to be the first button on the left. what should andrina do to place the mail merge button there?
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
The song about casey jones a railroad engineer who gives his life on the job would most likely gall under the folk song category of? a-work song b-nonsense song c-religious song d-ballad
Answers: 1
question
Computers and Technology, 23.06.2019 23:00
Computer programming is one type of what career
Answers: 1
You know the right answer?
For c++ ( make sure it runs properly)

8.12 (simulation: the tortoise and the hare) in t...
Questions
Questions on the website: 13722360