Display the resulting answers to the screen

Assignment Help Basic Computer Science
Reference no: EM13996570

In reverse Polish notation the operators follow their operands. To add 3 and 4, one would write "3 4+" rather than "3 + 4". If there are multiple operations, the operator is given immediately after its second operand. The expression written "3 - 4 + 5" would be written "3 4- 5 +" in RPN: first subtract 4 from 3, then add 5 to that. An advantage of RPN is that it obviates the need for parentheses that are required by infix notation.

Your assignment is to produce a Reverse Polish Notation calculator that operates on input files.

1. First, ask the userfor the location of an input text file. Open this file.

2. Read in the input text file, and interpret the input data as RPN. Each line in the file should be interpreted as its own math problem.

3. Display theresulting answers to the screen, with each output line corresponding to the input lines.

4. If a math problem has an error in its syntax, display SYNTAX ERROR for that line and continue with the next problem.
Do not support unary operators. The user will not beable to enter negative numbers. (However, your program must still be able to handle internal numbers that are negative and negative results.)
Add support for the following binary operators, written exactly as shown: + - * / % pow
The pow operator should raise the first operand to the power of the second operand. The % operator should perform modulo division. The C standard library supports modulo division of floating point numbers, whereas the built-in C++ modulo division operator only supports integer division. You will need to usethe library function in order to handle the potential decimal number inputs from the user.

Support decimal number inputs as well as integer number inputs.
Implement operators using good object oriented design techniques. Represent each type of data the user could enter as a class. There should be anoperandclass that represents anumber, and several classes that inherit froma base class ofoperator, which represents each operator implemented. The base operatorclass should have a function that applies the operator to two operands that are passed in as arguments to the function. Each operator class that inherits should then override the function with one that actually performs that operation. Each child class should also have agetter that returns the operator symbol.Allof these classes should inherit from a common ancestor class namedsymbol. Example boilerplate code follows:
class symbol { };

class operand : public symbol { ... };

class operator : public symbol { ... };

class add : public operator { ... };

...

class pow : public operator { ... };
You should take the input expressions and create the appropriate classes to represent the input data, and then run the functions on that data to obtain your result.
You maynotstore type information about the classes in the classes themselves. i.e. Do not do what we did with the type field in rock/paper/scissors.
Your project submission should be logically laid out and use good object oriented design. Pretend that this project might one day be extended by additional developers by adding additional operators or other features. Points may be deducted if your assignment does not allow for flexibility in the program.
There will be oneor more whitespace characters between two numbers. There will be zeroor more whitespace characters between a number and a symbol or two symbols.
Sample Input:

3 4 5.0 * -

7

4. * 8 30 +

banana

9 10 + 30 -

4. 7 3-+ 2 -3+

900 40.65- 20 +

45.2 23.999%

Sample Output:

-17

7

SYNTAX ERROR

SYNTAX ERROR

-11

9

879.35

21.201

Reference no: EM13996570

Questions Cloud

Functionality for a contact management system : logging in a user, and maintaining contact information. Within each use case, create the expected flow (happy-path) and one alternate flow (an exception).
Find the various changes in entropy due to melting of ice : Find the various changes in entropy due to the melting of the ice. What is the change in entropy, NS, of the block of ice? What is the change in entropy, NS, of the lake?
How fast will this person have to crank the hand pedals : A subject weighing 140 pounds wants to exercise at 4 METs on the arm ergometer. If the resistance is set at 1.5 kp, how fast will this person have to crank the hand pedals (assume the flywheel moves 2.5 m per pedal revolution)?
What is your opinion of customer service : What is your opinion of customer service? Is this something only marketing or the customer service department should emphasize, or is customer service something that should be a priority with everyone in the organization
Display the resulting answers to the screen : Read in the input text file, and interpret the input data as RPN. Each line in the file should be interpreted as its own math problem.
What amount of air passing per minute through wtg swept area : What is the amount of air passing per minute through the WTG swept area if the rotor radius is 40m, the air flux is 12 kg/((m^2)*(s^2)). would the amount of air passing through change if the temperature changed on site with +7C degree? (Yes or No,..
What is your opinion or experience with free samples : What is your opinion or experience with free samples? Do they work? Apparently they do for some companies selling product at Costco? What businesses are there today that should probably avoid free sampling
How it might be used for the small business : Analyze several of the possible choices for CPU, memory, storage, and input/output peripherals, and then make a recommendation for a specific file server solution. Justify the choices that you recommend.
What is the momentum of the system : What is the momentum of the system? Determine the speed and mass of the second particle emerging from the collision.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Functions involving double hash on c++

Functions involving double hash on c++

  Benefits and drawbacks of each format for users

Examine the benefits and drawbacks of each format for users. Determine whether you agree or disagree that Blu-ray was the superior choice technologically over HD-DVD. Provide a rationale for your response.

  What is greenhouse effect

What is Greenhouse effect - We are legally, ethically,and socially required to green our IT products, applications, services, and practices - is this statement true? Why?

  The xor gates are ideal for testing parity

The XOR gates are ideal for testing parity because even-parity words produce a _____ output and odd-parity words produce a _____ output

  Old website from an externally hosted solution

Tony's Chips has recently been sold to a new independent company. The new company has hired you to manage a project that will move the old Website from an externally hosted solution to an internal one. The company's leadership is very concerned about..

  Use of universal quantification

Let L1, L2, ..., Ln be distinct lines in the Euclidean plane, and let A be the set of points formed by intersections of these lines. Characterize A using set notation and quantifiers.

  Write the windows cli net commands

Write the Windows CLI NET commands that will turn the Spooler service OFF and then ON.

  Reduces the program to an icon on the taskbar

Reduces the program to an icon on the taskbarReduces the program to an icon on the taskbar

  How volvo car corporation transforms data into knowledge

Use at least three (3) quality resources in this assignment. Note: Wikipedia and similar Websites do not qualify as quality resources

  Discuss the merits of unified architectures vs. proprietary

Discuss the merits of unified architectures vs. proprietary technologies in ensuring standards compliance and cybersecurity?

  Program to clear register b

Write a program to clear Register B, and then add the number three to B seven times. Use the BNE instruction with DECA.

  Identify and select appropriate technologies to protect

• Identify and select appropriate technologies to protect against the risks that were identified, and provide an explanation as to why the technology was chosen.

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