Program first asks user to input ‘y’ or ‘n’ as a yes or no. If the user enters a valid input then program asks the user to input a string. After the string is entered program checks step-by-step each state of the DFA. If any change of the state occurs, program changes itself accordingly. It outputs the character with its current state at each iteration. If at any iteration, the input goes on a trap state, then it will remain there till the rest of the string iteration is completed. There are separate functions to check the states and to change the state accordingly. After an input is completed, the program then prints Accepted or Rejected based on the string evaluation. The string is only considered accepted if it terminates on either q10 or q12. In the rest of the all cases, the string is rejected. The program has handled almost every case that I have given to it. For mine test case the program is working effectively.
- ww.com (accept)
- www.com (accept)
- wwww.com (accept)
- 1.com (trap - reject)
- 2.com (trap - reject)
- www.google.com (accept)
- www.lhr.nu (trap – reject)
- www.google (reject)
- www.lhr.nu.edu.pk (trap-reject)
- .com (trap-reject)
- .pk (trap – reject)
- lhr.com (accept) These are just some of the strings, however, I have tested many.