Evaluates infix expressions of unsigned integers

Assignment Help JAVA Programming
Reference no: EM132099316

Specification

Design, write and test a program that evaluates infix expressions of unsigned integers using two stacks. The main class will be P1GUI. It should create a Swing based GUI that allows the user input an infix expression and displays the result.

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

199_figure.jpg

Another class, InfixEval, should contain the code to perform the infix expression evaluation. For infix expression evaluation, two stacks will be used: a stack of operands and a stack of operators. The pseudocode for performing that evaluation is shown below:

tokenize the string containing the expression
while there are more tokens
get the next token
if it is an operand
push it onto the operand stack
else if it is a left parenthesis push it onto the operator stack
else if it is a right parenthesis
while top of the operator stack is not a left parenthesis
pop two operands and an operator perform the calculation
push the result onto the operand stack
pop top of the operator stack and ignore it (i.e. it is a left parenthesis) else if it is an operator
while the operator stack is not empty and
the operator at the top of the stack has higher
or the same precedence than the current operator
pop two operands and perform the calculation
push the result onto the operand stack
push the current operator on the operators stack
while the operator stack is not empty pop two operands and an operator perform the calculation
push the result onto the operand stack
the final result is at the top of the operand stack

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

Your program is only expected to perform correctly on syntactically correct infix expressions that contain integer operands and the four arithmetic operators + - * /. It should not, however, require spaces between tokens. The usual precedence rules apply. The division performed should be integer division. A check should be made for division by zero. Should the expression contain division by zero, a checked custom exception DivideByZero should be thrown by the method that performs the evaluation and caught in the main class, where a JOptionPane window should be displayed containing an error message.

Your program should compile without errors.

The Google recommended Java style guide should be used to format and document your code. Specifically, the following style guide attributes should be addressed: header comments include filename, author, date and brief purpose of the program; in-line comments used to describe major functionality of the code; the meaning and the role of variables and constants are indicated as code comments; meaningful variable names and prompts applied; class names are written in UpperCamelCase; variable names are written in lowerCamelCase; constant names are in written in All Capitals; braces use K&R style.

In addition, the following design constraints should be followed: declare all instance variables private; avoid the duplication of code.

2. Submission requirements

Submit the following to the Project 1 assignment area no later than the due date listed in your LEO classroom.

1. All .Java source files (no other file types should be submitted) and the output file generated by the program. The source code should use Java code conventions and appropriate code layout (white space management and indents) and comments. All submitted files may be included in a .zip file.

2. The solution description document P1SolutionDescription (.pdf or .doc / .docx) containing the following:

(1) Assumptions, main design and error handling;

(2) 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;

(3) A table of test cases including the test cases that you have created to test the program. The table should have 5 columns indicating (i) what aspect is tested, (ii) the input values, (iii) the expected output, (iv) the actual output and (v) if the test case passed or failed. Each test case will be defined in a table row.

(4) Relevant screenshots of program execution;

(5) Lessons learned from the project;

Verified Expert

To calculate infix Expression , we have created class called Evaluate string,in that we created two stacks one for operator and one for operand. And we checked every condition,two methods one for to calculate higher precedence and another for to calculate result. Another class to create GUI using swing and UnsupportedExceptionClass for handling exception and for message.

Reference no: EM132099316

Questions Cloud

What rate of return would you have earned : What rate of return would you have earned on your investment had you purchased the shares on December 5, 2007?
Appropriate for a corporation that emphasizes creativity : Is the evaluation and control process appropriate for a corporation that emphasizes creativity? Are control and creativity compatible?
Managing business unit following a differentiation strategy : What skills should a person have for managing a business unit following a differentiation strategy? Why?
What functions do labor unions perform at the local level : What functions do labor unions perform at the local level? What are some techniques to create synergy in culturally or generationally diverse workplaces?
Evaluates infix expressions of unsigned integers : Data Structures and Analysis CMSC 350 - write and test a program that evaluates infix expressions of unsigned integers using two stacks
How can perceptions affect customer service : How can perceptions affect customer service? What are some strategies for eliminating service barriers using styles of behavior?
Develop a range of strategy to implement innovative thinking : Develop a range of strategies to implement and/or increase innovative thinking within the team or organisation.
Describe the sources of personality differences : List and describe the sources of personality differences. What are the characteristics of a "Type A" personality? Describe the situational leadership model.
Target practice-segmentation and market research : The North American branch of our international car company researched and developed a specific car model targeted at the U.S. youth market.

Reviews

len2099316

8/29/2018 10:38:42 PM

Solution description document P1SolutionDescription includes all the required sections (appropriate titled). No solution description document is included Source code follows Google recommendation Java style Source code does not follow Google recommendation Java style Comment blocks with class description included with each class Comment blocks with class description not included with each class Source code is commented and indented Source code is not commented and indented

len2099316

8/29/2018 10:38:30 PM

Test cases table is defined and included in the P1SolutionDescription document Test cases table is not defined and included in the P1SolutionDescription document All operators included in test cases Some operators not included in test cases Test cases include expressions without spaces Test cases don't include expressions without spaces Test cases include cases to test precedence Test cases do not include cases to test precedence Test cases include cases with parentheses Test cases do not include cases with parentheses Test cases include a case to test division by zero Test cases do not include a case to test division by zero

len2099316

8/29/2018 10:38:24 PM

Uses good object-oriented design practice regarding code efficiency, encapsulation and information hiding, class and code reuse, high cohesion of classes, avoiding code duplication. Does not use good object-oriented design practice resulting in code efficiency, encapsulation and information hiding, class and code reuse, high cohesion of classes, avoiding code duplication. 10 points 0 points Produces correct value for all operators Does not produce correct value for some operators Correctly parses expressions without Does not correctly parse expressions Functionality space delimiters without space delimiters Correctly implements precedence Does not correctly implement precedence Correctly evaluates parenthesized expressions Does not correctly evaluate parenthesized expressions

len2099316

8/29/2018 10:38:16 PM

Grading Rubric: Criteria Meets Does Not Meet Design 5 points 0 points GUI is hand coded and matches required design GUI is generated by a GUI generator or does not match required design Supplied algorithm is used Supplied algorithm is not used Contains separate class for expression evaluation Does not contain separate class for expression evaluation All instance variables are private Instance variables are not private Contains checked exception class Does not contain checked exception 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