Computers and Technology

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.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 19:10, kaiya789
10. when you create a pivottable, you need to specify where to find the data for the pivottable. is it true
Answers: 2
image
Computers and Technology, 23.06.2019 06:00, hilarydodard7099
Which statistical function in a spreadsheet you to see how far each number varies, on average, from the average value of the list?
Answers: 2
image
Computers and Technology, 23.06.2019 11:30, kieante01
The most accurate readings that you can take on an analog vom are when the meter's pointer is at the a. center scale. b. extreme right. c. near right. d. extreme left.
Answers: 1
image
Computers and Technology, 23.06.2019 12:40, Emilyvite6251
According to the video what are some tasks petroleum engineers perform check all that apply
Answers: 2
Do you know the correct answer?
For c++ ( make sure it runs properly)

8.12 (simulation: the tortoise and the hare) in t...

Questions in other subjects:

Konu
Mathematics, 19.02.2020 02:55