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, 22.06.2019 18:30, smariedegray
All of the following are characteristics that must be contained in any knowledge representation scheme except
Answers: 3
image
Computers and Technology, 23.06.2019 09:30, rowdycar313p0ao5k
[java] create an application called registrar that has the following classes: a. a student class that minimally stores the following data fields for a student: - name - student id number - number of credits - total grade points earned and this class should also be provides the following methods: - a constructor that initializes the name and id fields - a method that returns the student name field - a method that returns the student id field - methods to set and retrieve the total number of credits - methods to set and retrieve the total number of grade points earned. - a method that returns the gpa (grade points divided by credits) b. an instructor class that minimally stores the following data fields for an instructor: - name - faculty id number - department the following methods should be provided: - a constructor that initializes the name and id fields - methods to set and retrieve the instructor’s department. c. a course class that minimally stores the following data for a course: - name of the course- course registration code- maximum number of 35 students- instructor- number of students- students registered in the course (an array)the following methods should also be provided: - a constructor that initializes the name, registration code, and maximum number of students- methods to set and retrieve the instructor- a method to search for a student in the course; the search should be based on an id number.- a method to add a student to the course. if the course is hill, then an exception with an appropriate message should be raised (try creating your own exception class for this). also, be sure that the student is not already registered in the course. the list of students should be in the order that they registered.- a method to remove a student from the course. if the student is not found, then an exception with an appropriate message should be raised (use the same exception class mentioned a method that will allow course objects to be output to a file using object serialization- a method that will allow course objects to be read in from a file created with object serializationyou will note that the student and instructor classes described above have some commonality. create aperson class that captures this commonality and uses it as a base class for student and instructor. this class should be responsible for the name and id fields and also provide atostring method that returns a string of the form name, id. this will be the inheritedtostring method for the student and instructor classes.1. draw a uml diagram for diss application.2. implement the previous classes in java. write a main program that can serve as a test class that tests all of the methods created and demonstrates that they are working
Answers: 2
image
Computers and Technology, 23.06.2019 20:30, cristalcastro901
If an appliance consumes 500 w of power and is left on for 5 hours, how much energy is used over this time period? a. 2.5 kwh b. 25 kwh c. 250 kwh d. 2500 kwh
Answers: 1
image
Computers and Technology, 23.06.2019 22:30, BilliePaul95
Janice usually works on a particular workbook that contains all business related data. she decides to keep a backup of all the data in a separate workbook. she opens a new workbook to transfer the data. which option should she use to copy all the data from one workbook to another workbook?
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 in other subjects:

Konu
Mathematics, 06.03.2022 17:00
Konu
Computers and Technology, 06.03.2022 17:00