Reference no: EM132200862
Write a Java program that takes as input a DFA M and an input string w, simulates M on w, and outputs ACCEPT if M accepts w, and REJECT if M does not accept w.
You will assume that the alphabet is ? = {0,1} and that the DFA has at most 20 states. The states are labeled 1,2, ...20. Suppose that the starting state is 1. In order to input the DFA you will do the following:
• You will ask the user to enter the transition function d (either you can prompt the user by asking questions of the type "enter the state M goes to from state 14 and symbol 1", or the user will just enter a list of 3-tuples, where a 3-tuple has the form (old-state, symbol, new state).
• Next, you will ask the user to enter the set F of accepting states. Next you will ask the user to enter the input string w.
Test your program with the DFA from Example 1.11, page 38 ( run that DFA on 3 strings that are accepted and 3 strings that are not accepted), and the DFA from Example 1.68 (a), page 76 ( run that DFA on 3 strings that are accepted and 3 strings that are not accepted). Turn in:
• The code of your program (should be well documented)
• o A short description of your program (1 page should be enough), including a presentation of the data structures that you have used to represent the DFA and the input string w (probably some types of arrays or linked lists).
• o 2- 3 printouts with the screens when you run the program.