Write a java program that meet all of the given requirements

Assignment Help JAVA Programming
Reference no: EM131669910

Assignment

Part 1

Write a Java program, in file Logic.java that can be run as follows, assuming that there is a file called f in your current directory:

[ID@serv15 project]$ java Logic f

When your program is run, it should read a description of a network of logic gates and wires from the file f (or from any other file you elect to use). Here is an example description:

gate A and 1.0
gate B or 0.5
wire Aout B in1 0.1
wire B out A in1 0.3
-- another gate
gate C neg 0.5

wire Aout C in 0.1
wire C out B in2 0.1

For gates, the arguments in the source file are:

• The gate name (textual, even numbers are legal)
• The gate type (textual, for now, this has no meaning)
• The gate's time delay (a positive floating point number)

For wires, the arguments are:

• The wire source (a gate name)
• The source pin name (textual, for now, this has no meaning)
• The wire destination (a gate name)
• The destination pin name (textual, for now, this has no meaning)
• The wire delay (a positive floating point number)

Note in the above that we don't use punctuation to indicate a pin of a gate, for example, A.out, we just use a space.

A significant part of this assignment is that your program must tolerate and appropriately report errors in the input. That is, numbers must be given where expected, no gate name may be defined more than once, all gate names referenced in wire descriptions must have been declared before use, no input pin of a gate may also be used as an output, and no input pin may be used more than once.

If and only if there are no errors in the input, your program should generate as output to standard output (System.out) a reconstruction of the the input, although the order of gates and wires in the output may be changed, spacing may be standardized, and comments may be lost. Furthermore, numeric fields may be output in equivalent form - so for example, 05.6 or 5.600 might bothe end up being output as 5.6.
Error messages should be output to standard error (System.error) and should reasonably document the error, for example:

cannot open file named xyzzl.bug
shoe found where gate or wire expected
gate X illegally redefined
wire X out Y in undefined source
wire X Z delay expected

When there are errors, the output to standard output should include all correct parts of the input and, if it includes incorrect parts, those should make sense. The format of the error messages and the output of incorrect parts of the input are deliberately underspecified. You have design decisions to make here.

Note: For now, the count of the number of inputs permitted on a gate is just a number. Later, we will add code to enforce this: A 3 input gate must have exactly 3 wires to its inputs, and we will eliminate this field on gates that only have one input (neg, for example). If you want extra work, try enforcing this.

Part 2

Write a Java program, in file Logic.java that meets all of the requirements for MP2 and also supports the following gate types:

and
or
Each gate has inputs named in1 and in2 and one output named out.
not
Each gate has one input named in and one output named out.
const

This has outputs named true and false and no inputs

Wires may connect outputs to inputs. Each output may be connected to zero or more inputs, with each connection made by a distinct wire. Exactly one wire must connect to each input. Any attempt to connect inputs or outputs with names that are not supported by that kind of gate must be detected as an error.

In addition to checking the above correctness criteria, your program must be resiliant in the face of input errors of the sort that MP2 was expected to handle, and because you now have access to a ScanSupport class, it your code should work better than your code for MP2.

As with MP2, your program should generate either error messages to standard error or output a reconstruction of the circuit to standard output. All error messages should reasonably document the error.

Attachment:- mp2code.rar

Reference no: EM131669910

Questions Cloud

Relationship between unemployment and inflation : Are shocks to productivity or shocks to investment more likely to explain the negative relationship between unemployment and inflation?
List the entire contents of the database : List the entire contents of the database. List records that contain a specific field value. List records that do not contain a specific value.
General public and a sample of economists : Robert Shiller asked a sample of the general public and a sample of economists the following question: "Do you agree that preventing high inflation
What are the legal and ethical implications of change : What are the legal and ethical implications of change?How should current employees and leaders begin to prepare for this change?
Write a java program that meet all of the given requirements : Write a Java program, in file Logic.java that meets all of the requirements for MP2 and also supports the following gate types.
Analyse a case study related to programming : MN404 - Fundamentals of Operating Systems and Java Programming - Determine the classes that are required for the design minimum of four classes
How to find ways of lowering production costs : You are the leader of a cross-functional work team whose goal is to find ways of lowering production costs. Your team of eight employees has become mired.
Research the premium brand management : Research Paper - Industry linked case study. Based on the current Premium/Luxury Brand landscape, research the premium brand management and marketing aspects
Steps to help team develop into cohesive and efficient unit : Budgets are tight, so you won't have the opportunity to meet with your teammates in person to get to know one another.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Implement/update specific methods for the dfs of a graph

implement/update specific methods for the DFS of a graph; for at least 2 graphs (1 being the provided one), show the DFS order of vertices in the graph, and for each node,

  Fill a bag with the keywords of the java language

Create a class bag (multiset) that uses an expandable array to store the bag items. The item type must be a Java String type; that is, the bag will store strings of characters. The class should have the methods listed below. Create a main class to te..

  Create listener objects for each jcombobox

Create listener objects for each JComboBox that set the background color of the panel when the user selects an integer. Use the current values supplied by the JComboBox objects to determine the background color.

  Design and create an animated clock

Design and create an animated clock that will be displayed in the Mars Dome - Write the page in validated HTML5

  When the user presses a button

When the user presses a button, get the text from text field. Now extract the words from the text one at a time and find the largest word of length 4 or more. Let's call this largest word X for now. In response, create a question based on the length ..

  Write java class that declares named constant to hold number

Write a Java class that declares a named constant to hold the number of quarts in a gallon (4). Also declare a variable to represent the number of quarts needed for a painting job, and assign an appropriate value-for example, 18.

  Implement a method with three arguments

Implement a method with three arguments: a graph, a starting vertex number, and an ending vertex number. The method determines whether there is a directed path from the starting vertex to the ending vertex.

  How to write this method

How to write this method - Positive numbers rotate to the left, and negative numbers rotate to the right - the following client code would behave

  Create a computer class

Create a computer class and assume computers have the following fields: String manufacture, double price, int year

  Write a program to that finds lowest n closing dow jones

You are to write a program to that finds lowest N closing Dow Jones Industrial averages and their dates in order by closing average. The program should prompt for the number of lowest closing averages requested by the user to be output.

  Write a method that takes two integers as parameters

Write a method that takes two integers as parameters and returns trueif the first integer is evenly divisible by the second integer, false otherwise.

  Write a generic class

Write a generic class (using Java generics) called Pair that stores two values of the generic type.  It should have a constructor to set them, two methods getfirst() and getsecond() to retrieve them.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd