Question: Design and implement a Web page named dotrace.html that allows the user to simulate a race between two dots. Your page should look something like

Design and implement a Web page named dotrace.html that allows the user to simulate a race between two dots. Your page should look something like the one in Figure 11.15. The length of the race (i.e., the goal distance) is entered by the user in a text box, and the positions of the two dots (initially 0) are displayed in text spans. Each time the user clicks the button labeled "Take a Step", each dot should move forward a random amount (either one, two, or three units). When one of the dots crosses the finish line-meaning that its current position is greater than or equal to the goal distance-an alert box should appear to identify the winner. Note that it is possible for the dots to tie if both cross the finish line on the same step. Thus, your code must be able to recognize a tied race and display an appropriate message in the alert box.

Step by Step Solution

3.27 Rating (165 Votes )

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

Document Format (1 attachment)

Word file Icon

1409-C-S-O-S(1059).docx

120 KBs Word File

Students Have Also Explored These Related Operating System Questions!