Writing a program that converts prefix expressions

Assignment Help JAVA Programming
Reference no: EM133424554 , Length: 3 pages

Data Structures and Analysis

Project

The first programming project involves writing a program that converts prefix expressions to postfix and postfix expressions to prefix. Customary infix expression place the operator between the two operands. In a prefix expression, the operator comes before the two operands. In a postfix expression it comes after them. One benefit of prefix and postfix expressions is that they never require parentheses nor rules regarding precedence or associativity.

The program for this project should consist of three classes. The main class should create a GUI that allows the user to input an expression in either prefix or postfix and convert it to postfix or prefix, respectively. The GUI should look as follows:

1501_Java.jpg

 

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

The second class should contain the code to perform the conversions. The pseudocode for prefix to postfix, which requires two stacks, is shown below:

tokenize the string containing the prefix expression while there are more tokens
push the token onto a reversal stack if it is not a space while the reversal stack is not empty
pop the next token from the reversal stack if it is an operand
push it onto the operand stack else it is an operator
pop two operands off of the operand stack create a string with the two operands followed
the operator
push that string onto the operand stack pop the postfix expression off the stack
The pseudocode for the postfix to prefix conversion, which requires only one stack, is shown below:
tokenize the string containing the postfix expression while there are more tokens
get the next token if it is a space
skip it
else if it is an operand
push it onto the operand stack else it is an operator
pop two operands off of the operand stack create a string with the operator followed by
two operands

push that string onto the operand stack pop the prefix expression off the stack

Be sure to add any additional methods needed to eliminate any duplication of code.

The input expressions should not be required to contain spaces between tokens unless they are consecutive operands. The output expressions should always have a space between all symbols. A checked exception SyntaxError should be thrown by the methods that perform the conversions if an empty stack is ever popped or the stack is not empty once the conversion is complete. That exception should be caught in the main class, where a JOptionPane window should be displayed containing an error message.

You are to submit two files.

1. The first is a .zip file that contains all the source code for the project. 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. Every outer class should be in a separate .java file with the same name as the class name. Each file should include a comment block at the top containing your name, the project name, the date, and a short description of the class contained in that file.

2. The second is a Word document 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: EM133424554

Questions Cloud

Which big five ocean personality traits : Which Big Five OCEAN personality traits, intelligence components, or emotional-intelligence (EQ) components do you think will assist you in being a more
Why do you believe you have the emotional intelligence : As you reflect on the results of your self-assessment, do you believe you have the emotional intelligence to be a successful leader? Why or why not?
Explain what can happen to an entrepreneur : Identify and explain what can happen to an entrepreneur who is personally liable for their business in cases of legal, financial, or other business problems.
What does the o.j. simpson court case illustrate about : What does the O.J. Simpson court case illustrate about the role of criminal justice professionals and the operation of the criminal justice court system
Writing a program that converts prefix expressions : CMSC 315 Data Structures and Analysis, University of Maryland - writing a program that converts prefix expressions to postfix and postfix expressions to prefix
What was the original purpose of antitrust legislation : What was the original purpose of antitrust legislation? Why is it important to the U.S. economy? Please be sure to cite any outside sources you use in your
How might the genetic non-discrimination act affect : How might the Genetic Non-Discrimination Act affect the business practices, procedures, and operations of insurance companies?
Provide some recommendations for the improvement of src : Provide some recommendations for the improvement of SRC Scientific research Council in Jamacia They are apart of the agricultural ministry
Describe what sampling design you would use for this project : Assume there were no limitations on the project, describe what Sampling Design you would use for this project and the reason why. Assume there are around 900 SG

Reviews

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