Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

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

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages