Writing a program that accepts an arithmetic expression

Assignment Help JAVA Programming
Reference no: EM132113153

Project -

The second programming project involves writing a program that accepts an arithmetic expression of unsigned integers in postfix notation and builds the arithmetic expression tree that represents that expression. From that tree, the corresponding fully parenthesized infix expression should be displayed and a file should be generated that contains the three address format instructions. This topic is discussed in the week 4 reading in module 2, section II-B. The main class should create the GUI shown below:

1656_figure.png

The GUI must be generated by code that you write. You may not use a drag-and-drop GUI generator.

Pressing the Construct Tree button should cause the tree to be constructed and using that tree, the corresponding infix expression should be displayed and the three address instruction file should be generated.

The postfix expression input should not be required to have spaces between every token. Note in the above example that 9+- are not separated by spaces.

The above example should produce the following output file containing the three address instructions:

Add R0 5 9

Sub R1 3 R0

Mul R2 2 3

Div R3 R1 R2

It is not necessary to reuse registers within an expression as shown in module 2, section II-B, and you can assume there are as many available as needed. Each new expression should, however, begin using registers starting at R0.

Inheritance should be used to define the arithmetic expression tree. At a minimum, it should involve three classes: an abstract class for the tree nodes and two derived classes, one for operand nodes and another for operator nodes. Other classes should be included as needed to accomplish good object-oriented design. All instance data must be declared as private.

You may assume that the expression is syntactically correct with regard to the order of operators and operands, but you should check for invalid tokens, such as characters that are not valid operators or operands such as 2a, which are not valid integers. If an invalid token is detected a RuntimeException should be thrown and caught by the main class and an appropriate error message should be displayed. Below is an example:

1384_figure1.png

You are to submit two files.

1. The first is a .zip file that contains all the source code for the project, which includes any code that was provided. The .zip file should contain only source code and nothing else, which means only the .java files. If you elect to use a package the .java files should be in a folder whose name is the package name.

2. The second is a Word document (PDF or RTF is also acceptable) that contains the documentation for the project, which should include the following:

a. A UML class diagram that includes all classes you wrote. Do not include predefined classes. You need only include the class name for each individual class, not the variables or methods.

b. A test plan that includes test cases that you have created indicating what aspects of the program each one is testing.

c. A short paragraph on lessons learned from the project.

Reference no: EM132113153

Questions Cloud

What are possible causes of performance gaps : What are possible causes of performance gaps that might need to be addressed in business?
To demonstrate your awareness of six important elements : To demonstrate your awareness of six important elements of business writing: purpose, audience, context, medium, scope, and tone.
Develop and implement performance plans : Why is it necessary to develop and implement performance plans in accance with organization's goals and objectives?
Integrity and credibility in business : How do you think leader's work and attitudes contribute to the organization's integrity and credibility in business?
Writing a program that accepts an arithmetic expression : CMSC 350 Project - The second programming project involves writing a program that accepts an arithmetic expression of unsigned integers in postfix notation
What strategic problems does robin hood have : What strategic problems does Robin Hood have? What are some issues in this organization's external environment?
Personal values of employees align : Why is it important that the personal values of employees align with those of the organization?
Why are action plans necessary at restaurant : Why are action plans necessary at restaurant especially in management?
Identify three new concepts you did not previously have : Identify three new concepts you did not previously have any background on and state how this new information impacts your career or you personally.

Reviews

len2113153

9/15/2018 12:00:54 AM

Design - GUI is hand coded and matches required design, Inheritance hierrachy with at least 3 classes is used, Other classes are used to support good object-oriented design, All instance data is private. Functionality - Produces correct fully parenthesized infix expressions for all input, Produces correct three address file for all input, Correctly parses expressions without space delimiters, Registers restart at R0 on each new expression. Test Cases - All operators included in test cases, Test cases include expressions without spaces, Test cases include a case to test invalid token beginning with a digit. Test cases include a case to test invalid operators. Documentation - Correct UML diagram included. Comment blocks with class description included with each class.

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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