Write and test a method that simulates a general finite automaton. Your program should enable the computer to simulate any given finite automaton and then to simulate, for any given word, step-by-step, how this automaton decides whether this word is accepted by the automaton.