Question: Assignment #24: Tortoise and the Hare (Project) Your challenge for this assignment is to create a racing game. Specifically, you are going to create that

Assignment #24: Tortoise and the Hare (Project)

Your challenge for this assignment is to create a racing game. Specifically, you are going to create that great race between the Tortoise and the Hare. Unlike the first race, this race will take place up a slippery mountain. Here are the specifics for the assignment:

The race will cover a distance of 70 squares. Each contestant will start at square 1. 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 the winner. Because they are running up a slippery mountain, the contenders may occassionally lose ground.

There is a clock that ticks every second. With each tick of the clock, your program should adjust the position of the animals according to the following rules.

Animal Move Type Percentage of the time ActualMove
Tortoise Fast Plod 50% 3 squares to the right
Slip 20% 6 squares to the left
Slow Plod 30% 1 square to the right
Hare Sleep 20% No movement
Big Hop 20% 9 squares to the right
Big Slip 10% 12 squares to the left
Small Hop 30% 1 square to the right
Small Slip 20% 2 squares to the left

Use variables to keep track of the position of the animals (i.e., position numbers are 1 - 70). Start each animal at position 1. If an animal slips left before square 1, move the animal back to square 1.

Generate the percentage in the preceding table by producing a random number integer, i, in the range 1

Begin the race by printing

BANG !!!!!

AND THEY ARE OFF !!!!!

Then for each tick of the clock, print a 70 position line showing the letter T in the position of the tortoise and the letter H in the position of the hare. Occassionally, the contenders will land on the same square. In this case, the tortoise bites the hare and your program should print "OUCH!" beginning at that position. All print positions other than T, the H, or the OUCH! should be blank.

After each line is printed, test if either animal has reached or passed square 70. If so, then print the winner and terminate the simulation. If the tortoise wins, print out "Tortoise Wins !!!!!" If the Hare wins, print out "Hare Wins ; > ( " If both animals win on the same tick, print "It's a Tie!". If neither animal wins, perform the loop again to simulate the next tick of the clock.

***** PRINTF STATMENTS NO and This is programming with C*****

reference image of outcome:

Assignment #24: Tortoise and the Hare (Project) Your challenge for this assignment

T T N T H

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!