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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:00, Ltik11900
Write the command that can be used to answer the following questions. (hint: try each out on the system to check your results.) a. find all files on the system that have the word test" as part of their filename. b. search the path variable for the pathname to the awk command. c. find all files in the /usr directory and subdirectories that are larger than 50 kilobytes in size. d. find all files in the /usr directory and subdirectories that are less than 70 kilobytes in size. e. find all files in the / directory and subdirectories that are symbolic links. f. find all files in the /var directory and subdirectories that were accessed less than 60 minutes ago. g. find all files in the /var directory and subdirectories that were accessed less than six days ago. h. find all files in the /home directory and subdirectories that are empty. i. find all files in the /etc directory and subdirectories that are owned by the group bin."
Answers: 1
image
Computers and Technology, 23.06.2019 02:30, jalaholmes2027
Three out of five seniors remain undecided about a college major at the end of their senior year.
Answers: 3
image
Computers and Technology, 23.06.2019 03:00, tay9122
Jason, samantha, ravi, sheila, and ankit are preparing for an upcoming marathon. each day of the week, they run a certain number of miles and write them into a notebook. at the end of the week, they would like to know the number of miles run each day, the total miles for the week, and average miles run each day. write a program to them analyze their data. your program must contain parallel arrays: an array to store the names of the runners and a two-dimensional array of five rows and seven columns to store the number of miles run by each runner each day. furthermore, your program must contain at least the following functions: a function to read and store the runners’ names and the numbers of miles run each day; a function to find the total miles run by each runner and the average number of miles run each day; and a function to output the results. (you may assume that the input data is stored in a file and each line of data is in the following form: runnername milesday1 milesday2 milesday3 milesday4 milesday5 milesday6 milesday7.)
Answers: 3
image
Computers and Technology, 23.06.2019 15:20, manarhizam12
An ou structure in your domain has one ou per department, and all the computer and user accounts are in their respective ous. you have configured several gpos defining computer and user policies and linked the gpos to the domain. a group of managers in the marketing department need different policies that differ from those of the rest of the marketing department users and computers, but you don't want to change the top-level ou structure. which of the following gpo processing features are you most likely to use? a, block inheritance b, gpo enforcement c, wmi filtering d, loopback processing
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 in other subjects:

Konu
Mathematics, 03.07.2019 18:30