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 12:50
You have just been hired as an information security engineer for a large, multi-international corporation. unfortunately, your company has suffered multiple security breaches that have threatened customers' trust in the fact that their confidential data and financial assets are private and secured. credit-card information was compromised by an attack that infiltrated the network through a vulnerable wireless connection within the organization. the other breach was an inside job where personal data was stolen because of weak access-control policies within the organization that allowed an unauthorized individual access to valuable data. your job is to develop a risk-management policy that addresses the two security breaches and how to mitigate these risks.requirementswrite a brief description of the case study. it requires two to three pages, based upon the apa style of writing. use transition words; a thesis statement; an introduction, body, and conclusion; and a reference page with at least two references. use a double-spaced, arial font, size 12.
Answers: 1
question
Computers and Technology, 23.06.2019 00:00
Donna and her team of five have invented a new gadget for the science exhibition in their college. which intellectual property right will protect their invention?
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
What are ways to switch windows in excel? check all that apply. on the status bar, click the windows button, and then click the file name. on the task bar, click to display the excel jump list, and then click the file name. on the view tab, in the window group, click switch windows, and then click the file name. on the review tab, in the viewing group, click files, and then click the file name.
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Facial expressions and gestures are examples of messages.
Answers: 3
You know the right answer?
For c++ ( make sure it runs properly)

8.12 (simulation: the tortoise and the hare) in t...
Questions
question
Chemistry, 12.11.2019 20:31
question
Mathematics, 12.11.2019 20:31
question
Mathematics, 12.11.2019 20:31
question
English, 12.11.2019 20:31