The purpose of this programming assignemnt is to solidify your knowledge of Finite Automata with Output by means of a programming exercise.
A complete description of the problem is included in a memo from your instructor.
What you'll turn in
For each business day you turn in your project earlier you receive a
5% bonus. However, penalties increase by 5% as well. You can turn in your
assignment up to ten business days ahead of the deadline.
You may be asked to do a code review with your instructor.
I need your help in creating an application that reads the description of a Finite Automata with Output (Moore style) from standard input and then, given an input string -- again from standard input --, outputs (to standard output) the corresponding output string.
For simplicity, the input string will consist only of 0s and 1s.
Here is a description for the input and the output of your program.
The input always begins with a line by itself that reads BEGIN_FA_DESCRIPTION and ends with a line by itself that reads END_FA_DESCRIPTION. Each line in the input, between BEGIN_FA_DESCRIPTION and END_FA_DESCRIPTION, will have the following format:
stateNumber nextStateWhenInputIsZero nextStateWhenInputIsOne outputInThisStateIf a stateNumber is preceded by a >, then the state is the start state.
Here is an example of input for a FA with four states:
BEGIN_FA_DESCRIPTION >0 1 2 x 1 3 4 x 2 3 4 y 3 3 3 x 4 3 2 x END_FA_DESCRIPTIONAfter the description of the FA is read from standard input, your application will read (forever) from standard input input strings for the FA. As soon as a line is complete (the user hits Enter) your application will print the output corresponding to the given input and will go to the start state (waiting for more input).
Each line in the output (standard output) corrsponds to an input string.
Using the FA described by the sample above, let's assume the the input string is 01101. Then the corresponding output will be:
xxxyxxPlease note that the left-most output letter is the output of the FA in the initial state.
Please note that if your program reads input from standard input then it can get input from a file by using input redirection. Similarly, if the program writes to standard output, then the output can be easily written to a file by using output redirection.
For example, assign < myInputFile.din will get the input from the file named myInputFile.din (< indicates input redirection), and the output will be written to standard output (typically the monitor).
On the other hand, if you do assign > myOutputFile.out then the graph description will come from standard input (typically your keyboard) and the output will be written to myOutputFile.out (> indicates output redirection).
Finally, you can do both input and output redirection at the same time:
assign < myInputFile.din > myOutputFile.out
$Id: assign.html,v 1.1 2002/03/18 13:05:02 virgil Exp $