Here are some exercises that will allow you to practice designing finite-state machines. They do not need to be turned in as homework.
1. Design a finite-state machine that illustrates the operation of a digital watch with two function buttons. Each successive push of button 1 causes the watch to change from displaying the time, to setting the hours, to setting the minutes and back to displaying the time again and so on. Button 2 allows the user to increment either the hours or the minutes when the watch is in the appropriate state.
2. Consider a string consisting only of 0's and 1's. Design a finite-state machine that determines whether or not the total number of 1's in the string is divisible by 3 and then outputs an appropriate message.
3. Design a finite-state machine that counts the number of words contained
in the C-style comments of a C++ source file. A word is defined as any
maximal string of alphabetic characters. A C-style comment begins with
/* and ends with the characters
The comments may extend over more than one line.
4. Design a finite-state machine that counts the number of words contained
in both the C-style and C++ style comments contained in a C++ source file.
A C++ style comment starts with the characters
// and ends with
the newline character