Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

For this assignment, you will build upon existing classes to create a calculator that can  evaluate both infix and postfix expressions. You are given the following classes:

  •  Expression: an abstract class that models a mathematical expression. The class contains abstract methods verify and evaluate which must be defined in any class derived from Expression.
  •  InfixExpression: a class, derived from Expression, that models an infix expression (one in which the operator comes between its operands).
  • Calculator: a class with main method that serves as a calculator, reading in expressions as lines of text and evaluating them.

You are to extend the calculator so that it gives the user the option of entering expressions in infix notation or postfix notation (a.k.a. Reverse Polish notation). In order to accomplish this, you will need to perform the following tasks:

1. Define a new class named PostfixExpression that is derived from Expressionand models a postfix expression. Similar to the way that InfixExpression is defined, your new class will need to implement the verify and evaluate methods. Recall that a stack can be used to evaluate a postifix expression: each operand is pushed on the stack, and each operator is handled by popping two operands off the top, applying the operator, and then pushing the result.
Modify the Calculator class so that the main method first prompts the user as to whether they want to enter infix or postfix expressions for evaluation. Depending on their response, expressions of that type should be read in and evaluated.
Submission:
1) Upload your source code on CMS.
2) Submit a printout of your pprogram along with a copy of the output generated by running the program.
3) Arrange to meet one-to-one with your TA to do a short demonstration of your program in the lab and answer a few questions about the coding on due date or before.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91606833

Have any Question?


Related Questions in Computer Engineering

Several of the cameras in the lab can capture a greyscale

Several of the cameras in the lab can capture a greyscale image either as an 8 bit image, or as a 12 bit image. What would be the difference between them, and what would be the benefit of using one over the other? What w ...

Discuss the importance of using an access control model in

Discuss the importance of using an access control model in determining how employees in an organization should gain access to resources.

I really need help writing this c progam i have seen many

I really need help writing this C++ progam. I have seen many answers to this question on this site, but they are all deeply flawed. Design the following classes in C++. Person class is the base class for other classes. P ...

Need help with a java program that takes two arrays a and b

Need help with a Java program that takes two arrays a and b of length 5 storing int values, and returns the dot product of a and b. That is, it returns an array c of length n such that c[i]=a[i]*b[i].

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

Information systemsdirections answer the following if you

Information Systems Directions : Answer the following: If you were asked to develop a logical model of the registration system at a school, would it be better to use a top-down or bottom-up approach? Explain your reasoni ...

Research web server vulnerabilities by choosing a site and

Research web server vulnerabilities by choosing a site and determining what kind of platform it is running on. Do not scan the server, you can use a site such as Netcraft to determine what the website is running. See if ...

Question suppose now that after each turn a single six-face

Question : Suppose now that after each turn, a single six-face die is tossed. If it comes out to one, a single chip is removed from the fourth pile; otherwise, the board is left as is. Describe an efficient algorithm tha ...

Without doing any math or drawing a graph which is bigger

Without doing any math, or drawing a graph, which is bigger, compensating variation or equivalent variation for a tax? Consider an individual with Cobb-Douglas preferences over some good and all other goods. In what sens ...

How would the stock market soars and americans wealth

How would the stock market soars and Americans wealth expands significantly affect the econmony, by analyzing in the SRAS-AD diagram and determine the effects on real GDP and the General price level.

  • 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