# Program related in using RANDOM numbers using C.

• 09-11-2011
Ashleykaye
Program related in using RANDOM numbers using C.
I have an assignment and its quite difficult to me to make because im still a beginner and I badly need this before 12 midnight.
My assignment goes like this:

The tortoise and the hare, in this project you will recreate one of the truly great moments in history, namely the classic race of the tortoise and the hare.
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.

The two animals take turns in moving positions. Your program should randomly adjust the position of the animals according to the following rules:

Animal Move type Random No. Actual move
Tortoise Fast plod 1-5 3 squares to the right
Slip 6-7 6 squares to the left
Slow plod 8-10 1 square to the right
Hare Sleep 1-2 No move at all
Big hop 3-4 9 squares to the right
Big slip 5 12 squares to the left
Small hop 6-8 1 square to the right
Small slip 9-10 2 squares to the left

Keep track of the positions of the animals (values from 1 to 70). Start each animal at position 1 (i.e. the “starting gate”). If an animal slips below position 1, move the animal back to position 1. Generate a random integer i in the range 1 to 10. For the tortoise, perform a “fast plod” when i is between 1 and 5, a slip when 6 to 7 or a slow plod when 8 to 10. Use the same technique to move the hare.
Begin the race by printing “Bang!! And they’re off!!”. For each turn, update the race track. Occasionally 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. Test if either animal has reached or passed square 70. If so, then print the winner and end the program.

• 09-11-2011
agxphoto
If your program is not looping through the turns, then your problem is likely to be with control flow: do/while, for, if/then. Look at your overall plan for the program. There should probably be some type of loop that inspects whether or not a player has reached the goal. Nested inside that might be a loop counting the succession of turns.

If your computer class is structured well, then there are probably examples in the lessons of the textbook and class which should get you to an 80% solution. A lot of times homework will involve simple modifications to existing examples so that the student can show they can apply the concepts. The parts needed to build your answer should be in the past few chapters.
• 09-11-2011
CommonTater
Quote:

Originally Posted by Ashleykaye