Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB Clock game Write a program that will function as a simple clock game. The program will determine a random target between 5 and 15

MATLAB Clock game

Write a program that will function as a simple clock game. The program will determine a random target between 5 and 15 seconds. The player gets to set the direction of the clock either as up (1) or down (2). The player may pause (3) the clock and may end (4) the game. Any invalid input will be indicated by the program. If the player is able to stop the clock within 0.25 seconds of the target, the program will praise the player. An example of the game is shown below.

Your target is 9.06 seconds

Menu:

1. Up 2. Down 3. Pause 4. End

Please choose an action: 1

Total time is 0.00. The target time is 9.06.

Please choose an action: 3

Total time is 7.77. The target time is 9.06.

Please choose an action: 1

Total time is 7.77. The target time is 9.06.

Please choose an action: 3

Total time is 10.26. The target time is 9.06.

Please choose an action: 2

Total time is 10.26. The target time is 9.06.

Please choose an action: 3

Total time is 8.74. The target time is 9.06.

Please choose an action: 1

Total time is 8.74. The target time is 9.06.

Please choose an action: 3

Total time is 9.29. The target time is 9.06.

Please choose an action: 4

Total time is 9.29. The target time is 9.06.

Your time is 9.29 with 9 commands.

Winner! Winner! Chicken Dinner!

You are free to tailor the prompts and the game play.

Your program must do the following

Provide the original clock target

Use inputs 1, 2, 3, 4 as described

Indicate an invalid entry

Update the user as to the time that is on the clock

Display the clock and the number of commands when the player stops the clock

Anyhelp on where to start with this would be much appreciated or showing an example.

On how the time is calculated all my professor said was that I could use the randi commmand along with another to get it to calculate the decimal times.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

{ "name": "Joe Biden", "occupation":

Answered: 1 week ago