Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The contenders, tortoise and hare, begin the race at square 1 of 70, and each sq

ID: 3633670 • Letter: T

Question

The contenders, tortoise and hare, begin the race at square 1 of 70, and each square represents a possible position along the race course with a finish line at square 70. With each tick of the clock, the application should adjust the position of the animals according to the rules shown below(N.B: the contenders occasionally loose ground, because the course weaves its way up the side of a slippery mountain):

Animal

Move type

Percentage of the time

Actual time

Tortoise

Fast plod

50%

3 squares to the right

Slip

20%

6 squares to the right

Slow plod

30%

1 square to the right

Hare

Sleep

20%

No move at all

Big hop

20%

9 squares to the right

Big slip

10%

12 squares to the right

Small hop

30%

1 square to the right

Small slip

20%

2 squares to the right

Use variables to keep track of the positions of the animals, ranging from 1 to 70 ; use   random-generation to develop a simulation of the event.

I NEED HELP WITH THIS PROBLEM TO BE WRITTEN IN JAVA

Animal

Move type

Percentage of the time

Actual time

Tortoise

Fast plod

50%

3 squares to the right

Slip

20%

6 squares to the right

Slow plod

30%

1 square to the right

Hare

Sleep

20%

No move at all

Big hop

20%

9 squares to the right

Big slip

10%

12 squares to the right

Small hop

30%

1 square to the right

Small slip

20%

2 squares to the right

Explanation / Answer

please rate - thanks

import java.util.*;
public class tortouseAndHare
{public static void main(String []args)
{int finish=70,tort=1,hare=1,rtime=0;
System.out.println("ON YOUR MARK, GET SET BANG !!!!! AND THEY'RE OFF !!!!! ");
do
{hare=movehare(hare);
tort=movetort(tort);
print(tort,hare);
rtime++;
}while(tort<finish&&hare<finish);
if(tort>hare )
    System.out.println("TORTOISE WINS!!! YAY!!! ");
else if(tort<hare )
    System.out.println("Hare wins. Yuch. ");
else
    System.out.println("Would you believe IT'S A TIE!! ");
System.out.println("time of race: "+rtime+" simulated seconds ");
}
public static void print(int t,int h)
{int i;
if(h==t)
    {for(i=0;i<h;i++)
          System.out.print(" ");
    System.out.println("OUCH!!!");
    }  
else if(h<t)
    {for(i=0;i<h;i++)
          System.out.print(" ");
     System.out.print("H");
    for(i=0;i<(t-h);i++)
          System.out.print(" ");
     System.out.print("T");
    }
else
   {for(i=0;i<t;i++)
          System.out.print(" ");
     System.out.print("T");
    for(i=0;i<(h-t);i++)
          System.out.print(" ");
     System.out.print("H");
    }
System.out.println();
}
public static int movehare(int r )
{int num;
num=(int)(Math.random()*10);
if(num<2)
     r-=2;
else if(num<5)
      r++;
else if(num<6)
      r-=12;
else if(num<8)
      r+=9;
if(r< 1 )
      r=1;
return r;
}
public static int movetort(int t)
{int num;
num=(int)(Math.random()*10);
if(num<5)
   t+=3;
else if(num<7)
   t-= 6;
else
    t++;
if(t<1)
   t=1;
return t;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote