The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 399 Weeks Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Write a program in Java that simulates a race between a tortoise and a hare. Each runner begins at position 0 on the race track and advances a random number of steps (between 0 and 5) at each turn. The first runner to reach position 100 wins. Your program will print the positions of the tortoise and the hare after each turn, and it will declare who wins the race at the end.
You can use the Random class to generate random numbers as follows:
A????1 import the java.util.Random library
A????1 create a random number generator object: Random rng = new Random();
A????1 generate a random number between 0 and MAX: int randNum = rng.nextInt(MAX);
The program must use a while loop.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on-----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be-----------