Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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

Java, Programming

  • Category:- Java
  • Reference No.:- M92478611

Have any Question?


Related Questions in Java

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As