Draw a finite state machine (FSM) for a string representing a single time of day. Your FSM should accept times such as 12:36 pm, 1:59 am, 4:00 pm, 2:45 am. Note that there are no leading zeros. Also, "am" and "pm" are lowercase and hace no periods. A terminal error state is not neccesary. To make the task easier, you can make up any grouping you want. For example, you may wish to leat represent any digit, let <1> represnt the digit 1, let <012> represent and digit 0-2, and let represent a space. Time statements are formatted in many ways but we want your FSM to only accept the above time format -- not military time or any other time format.

Respuesta :

Answer:

View Image

Explanation:

A time clock could either start with 1 digit or 2 digit. It could be from 1:00-9:00 or 10:00-12:00.

So if it starts with 2 digit, then the first number must be a 1 because 10:00, 11:00, and 12:00 starts with a 1. That means the second digit after that must be between 0-2 hence the output <012>.

If it starts with 1 digit then the number could be from 1-9 for 1:00-9:00.

After the first few digit comes the colons <:>.

After the colons come the digits for the minutes.

The first digit for the minutes could be from 0-5 because minutes counts from 0:00-0:59. Also, this means that the second digit for the minute must be from 0-9.

After the digits for the minutes comes a space to seperate the numbers from the <am> and <pm>.

After the space you place in the <am> and <pm>

And this is just a rough sketch. You need to go back and replace all the non-digit numbers such as <:>, <a>, <p>, and <m> with some numerical representation for those letters.

Ver imagen GrandNecro
ACCESS MORE