Chat with us, powered by LiveChat © Paul Koester, Dallas County Community College, 2018 COSC 2425 – Computer Organization Lab - Study Help
  

© Paul Koester, Dallas County Community College, 2018

COSC 2425 – Computer Organization

Lab #3 – Moore Machine

Create a Java program which implements this Moore machine.

Requirements

1. The program must be written in Java.

2. It must request the initial state and the input. It displays

the machine’s output and the final state, as in the example

below.

3. The input is a string of zeros and ones only.

4. If the initial state or input is invalid, an error message is

produced. The program may, but is not required to use

Java exceptions in this case

5. The program must implement the entire Moore machine, not just the inputs below. The

instructor will test it with different input

Hint: There are many different ways to do this, but consider using an array of state objects. One way is
to declare this class,

// This class represents one state in a Moore machine

public class Moore {

private char state; // The name of the state

private String output; // The output displayed when this state is entered

int zero; // The index of the next state given an input of 0

int one; // The index of the next state given an input of 1

// Public constructors and methods here

Then in main you can create the array of states like

Moore[] mooreStates = new Moore[5];

mooreStates[0] = new Moore(‘ ‘, “”, 0, 0);

mooreStates[1] = new Moore(‘A’, “00 “, 2, 4);

mooreStates[2] = new Moore(‘B’, “01 “, 2, 3);

mooreStates[3] = new Moore(‘C’, “11 “, 4, 3);

mooreStates[4] = new Moore(‘D’, “10 “, 3, 1);

Upload: Your Java (.java) file.

Sample Output
Please enter the initial State:

D

Please enter the input:

111

The output is:

© Paul Koester, Dallas County Community College, 2018

10 00 10 00

The final State is: A

Please enter the initial State:

A

Please enter the input:

10010100

The output is:

00 10 11 10 00 01 11 10 11

The final State is: C

error: Content is protected !!