Question: *Need Help with Java* Operation - This application simulates a race between two runners. The runners differ in their speed and how often they need
*Need Help with Java*

Operation
- This application simulates a race between two runners. The runners differ in their speed and how often they need to rest. One of the runners, named Tortoise, is slow but never rests. The other runner, named Hare, is ten times as fast but rests 90% of the time.
- There is a random element to the runners performance, so the outcome of the race is different each time the application is run.
- The race is run over a course of 300 meters. Each time one of the runners moves, the application displays the runners new position on the course. The first runner to reach 300 meters wins the race.
- When each runner finishes the race, the application displays a message that indicates that the runner has finished.
Specifications
- The main method of the applications main class should create two runner threads and start them. One of the threads should be named Tortoise. It runs only 10 meters each move, but plods along without ever resting. The other thread should be named Hare. It should run 100 meters each move, but should rest 90% of the time.
- Each runner should be a separate thread created from the class named RunnerThread. This class should include four variables:
-a string representing the name of the runner
-an int value from 1 to 100 indicating the likelihood that on any given move the runner will rest instead of run
-an int value that indicates the runners speedthat is, how many meters the runner travels in each move
-an int value indicating the runners progress on the course
- The run method of the RunnerThread class should consist of a loop that repeats until the runner has reached 300 meters. Each time through the loop, the thread should decide whether it should run or rest based on a random number and the percentage passed to the constructor. If this random number indicates that the runner should run, the class should add the speed value for the runner. The run method should sleep for 300 milliseconds on each repetition of the loop.
Hint
- To determine whether a runner should run or rest, calculate a random number between 1 and 100. Then, have the runner rest if the number is less than or equal to the percentage of time that the runner rests. Otherwise, the runner should run.
Get set. . .Go! Tortoise: 10 Tortoise: 20 Tortoise: 30 Tortoise: 40 Tortoise: 50 Tortoise: 60 Tortoise: 70 Tortoise: 80 Tortoise: 90 Tortoise: 100 Tortoise: 110 Tortoise: 120 Tortoise: 130 Tortoise: 140 Tortoise: 150 Tortoise: 160 Hare: 100 Tortoise: 170 Tortoise: 180 Tortoise: 190 Tortoise: 200 Tortoise: 210 Tortoise: 220 Tortoise: 230 Tortoise: 240 Tortoise: 250 Tortoise: 260 Tortoise: 270 Hare: 200 Tortoise: 280 Tortoise: 290 Tortoise: 300 Tortoise: I finished! Hare: 300 Hare: Ifinished
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
