Program to evaluate postfix expressions using a stack

Assignment Help Programming Languages
Reference no: EM1358074

Program to evaluate postfix expressions containing complex numbers using a stack. This program should contain two classes. The first class Project2 should contain the two methods described below:

1. The main method, which performs the expression evaluation. The algorithm for evaluating a postfix expression requires a stack of Complex numbers. The pseudocode for evaluating postfix expressions is given below:
2. while not end of expression
3. switch next token
4. case complex number:
5. push the value onto the stack
6. case operator:
7. pop two operands from the stack
8. evaluate
9. push result onto the stack
10. pop the final result off the stack
The user should be allowed to enter and evaluate any number of expressions.
11. A class method called evaluate, which accepts two complex numbers and a operator and returns the result of performing the operation on those two numbers.
The second class should be a class named Complex. Each complex number should contain a real and imaginary part. Each should be of type double. This class should contain the following methods.

1. A constructor.
2. A class method named fromString that accepts a StringTokenizer positioned at a complex number and returns that complex number.
3. A toString method that converts a complex number to a string.
4. A add method that adds two complex numbers and returns the result.
5. A subtract method that subtracts two complex numbers and returns the result.
6. A multiply method that multiplies two complex numbers and returns the result.

Reference no: EM1358074

Questions Cloud

Calculate average monthly return and standard deviation : Following you will find the end of month values for both the Standard & Poor's 500 Index and Ford Motor Corporation common stock.
What is the friction force that acts on the bear : A parallel plate capacitor has plates of area 2.0*10^3 and plate separation 1.0*10^4m. find the capacitance of this system if air fills the volume between the plates.
Can schizophrenia be prevented : Read the box at the end of chapter 13 "Unresolved Issues: Can Schizophrenia be Prevented?" After reading the text and looking at the evidence for biological, psychological and social risk factors and remembering the diathesis-stress model of patho..
Introduction to organization leadership and change : What aspects of the key stakeholder's roles do you need to be aware of when communicating the results and what is your plan to address the possible reactions of key stakeholders to the results?
Program to evaluate postfix expressions using a stack : Program to evaluate postfix expressions containing complex numbers using a stack. This program should contain two classes. T
Explain how must government spending increase to eliminate : Explain how much must government spending increase to eliminate the GDP gap.
Explain sexual harassment can occur in a work place : Explain Sexual harassment can occur in a work place environment with employees of the organization and Explain the role or responsibility of the company in this situation.
Relevant financial information for investors : Assume there is a well-financed, one-year-old company in the biotech industry that is concentrating on developing chemical-based compounds that are aimed at developing drugs to reduce the effects or onset of Alzheimer's Disease.
Forecasting demand and employee supply : Discuss what the major Forecasting Demand and Employee Supply approaches are about. Address what types of Forecasting Demand

Reviews

Write a Review

Programming Languages Questions & Answers

  Create a multi-threaded competition

Create a multi-threaded competition

  Activity for pdus on project management institute-s web site

Several activity categories are given as qualifying for PDUs on project Management Institute's Web site. Recognize  these categories. In which categories would you place Chris's experience?

  Reservations system to be horizontal or vertical application

Top Sail Realty Situation: Top Sail Realty is one of the largest time-sharing and rental brokers for vacation cottages. Do you consider the reservations system to be a horizontal or a vertical application? Give reasons for your answer.

  Deisgn class contains data fields for height and surfacearea

Deisgn a class named Rectangle that contains data fields for height width and surfaceArea and a method named computeSurfaceArea?

  Include hyperlink for confirming order in online ticket

Include a check box for attending the Awards Event. Include a hyperlink for confirming the order. Make the link invisible to begin but display it after the Submit button has been clicked.

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Create a dtd for a small xml data set

Create a DTD for a small XML data set drawn from the Stanford course catalog. There are multiple departments, each with a department chair.

  Data members to store values of the two loans

A class that represents a person who belongs to a SACCO has two data members to store values of the two loans the person owes the SACCO. Add a parameterized constructor that initializes these loans using the two values passed as arguments.

  Questions on programing problem with the process of analysis

Questions on Programing Problem with the process of analysis and reflection that went on as you developed the project.

  Function to convert a decimal input into roman numerals

Write a function that converts a decimal input into Roman Numerals. Your function will take in a number and output a string.

  Give hypertext link of the internet location of program

Describe in one or two paragraphs what you observe. Give hypertext link of the internet location of the program (or applet) you found.

  Creating webpage using css

In creating a web page, depending on the information you are trying to convey. What are CSS?

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