Question
1. Write java programs that can build a DFA based on the specifications and then process the strings and decide whether they are accepted. 2.
1. Write java programs that can build a DFA based on the specifications and then process the strings and decide whether they are accepted.
2. Your code will need to read in two input files then output your answer to a file as well.
3. The user will type the names of the input files and the name of the output file to the command line (not through the keyboard terminal).
4. Then DFA.txt is the file that contains the specifications for a DFA;
5. Strings.txt is the file that contains some number of strings;
6. Answers.txt will be the file that you create to write your answer to, which contains the information that which of the strings are accepted by the DFA and which are not;
7. The users may choose other file names they desire but the order of them wont change. It means the first file will be the specifications of a DFA; the second file will be a set of strings; and the third file will be the answers.
8. Sample files are provided, but the sample input files are by no mean listing all testing cases. You have to add testing cases to the input file to test your program completely. What you can assume is that the input format will be the same as those sample input files.
9. The specifications of a DFA may or may not omit the transitions leading to a sink/dead state. That is to say, any missing transition may come out of a state is assumed to go into a sink/dead state (such a state may or may not be specified as one element of the set of states).
----------------------------------------------------------------------
-----DFA.txt-----
M = { States, Alphabet, Transition Functions, Starting State, Final States } where, States = { q0, q1, q2, q3, q4 }, Alphabet = { a, b }, Starting State = q0, Final States = { q0, q2, q3 }, Transition Functions = { ( q0, a, q1 ), ( q0, b, q4 ), ( q1, a, q4 ), ( q1, b, q2 ), ( q2, a, q3 ), ( q2, b, q0 ), ( q3, a, q1 ), ( q3, b, q2 ), ( q4, a, q4 ), ( q4, b, q4 ) }
-------------------------------------------
--------Strings.txt-----------
ababa abbaba abbab aaaab abbbb babaa
-------------------------------------------
-------Answers.txt----------------
aaaaab is accepted. aaaaaaaa is rejected. aaaaaaab is accepted. bbbbbbbbbb is rejected.
------------------------------------------------
Thank you in advance!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started