Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want a Java code about a simple state machine. Constructing a program that validates input using a state machine. Taking 2 command line parameters

I want a Java code about a simple state machine.

Constructing a program that validates input using a state machine.

Taking 2 command line parameters a state machine filename, then a filename of inputs to validate. For example:

run validator myStateMachine.txt myInputs.txt

That is the command line in Drjava.

State Machine: The state machine will come from a text file in the following space delimited format:

stateNumber inputCharacter transitionsToState

For example:

0 A 1

0 a 1

1 B 2

1 b 2

2 C 999

There are three terminal situations:

999 success when this state is reached, print Success and end.

failure (no transitions match) print Failure at position ___, found character _.

failure (input string ends early) print Input string ended before success transition.

Note each state can have ANY NUMBER (1 or more) of transitions to other states. The transitions do not have to happen in any specific order (for example state 1 could transition forwards to state 4 and state 5 could transition backward to state 2). States will be sorted in the text file (0,1,2,3,4, etc.).

Input File: The inputs to validate is some number (1 or more) of lines of text. Example:

abc

AbC

Both file have no space line.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions