Skip to content

Simple Reverse Polish Notation calculator. It works with integer numbers only and the basic operators (+, -, *, /). The division result is the integer part of it.

Notifications You must be signed in to change notification settings

crespo/reverse-polish-notation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Reverse Polish Notation Calculator

Simple Reverse Polish Notation calculator. It works with integer numbers only and the basic operators (+, -, *, /). The division result is the integer part of it.

How it works:

  1. Read a input.
  2. If it is an integer (operand), push to the stack.
  3. If it is an operator, pop the last and second-to-last operands off the stack, do the operation and then push it back to the stack.
  4. If it is empty, close the program.

Usage:

  1. git clone https://github.com/crespo/reverse-polish-notation.git
  2. cd ./reverse-polish-notation
  3. python main.py
  4. Type a integer number or a basic operator (+ = sum, - = subtraction, * = multiplication, / = division) and ↵ Enter.
  5. When you've finished, type ↵ Enter again and the program should stop.

Example:

an example of the algorithm working. it contains a CLI with the following user inputs: 10, 15, 5, /, 4, *, -, 10, +. The final result is 8

About

Simple Reverse Polish Notation calculator. It works with integer numbers only and the basic operators (+, -, *, /). The division result is the integer part of it.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages