Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/crespo/reverse-polish-notation

Simple Reverse Polish Notation calculator. It works with integer numbers only and the basic operators (+, -, *, /). The division result is the integer part of it.
https://github.com/crespo/reverse-polish-notation

calculator reverse-polish reverse-polish-notation rpn rpn-calculator

Last synced: about 2 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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](example.png "Example")