Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 1.05 KB

README.md

File metadata and controls

36 lines (29 loc) · 1.05 KB

RPNCalculator

Exercise: Basic Reverse Polish Notation (RPN) Calculator

The RPN notation is also known as postfix expression. The capabilities of the Calculator are as follows:

  1. Supports operations for sum, difference, division, multiplication.
  2. Supports floating point operations.
  3. Use '^' for exponent operator. values entered as "X Y ^" are calculated as X to the power of Y.
  4. Use '%' for the percent operation. values entered as "X %" are calculated as X/100.
  5. Use ‘!’ for Factorial (unary operation).

Sample Input and Output:

  1. Input: 1 2 3 + - Output: -4
  2. Input: 6 2 * 3 / Output: 4
  3. Input: 2 3 ^ 4 5 + + Output: 17
  4. Input: 50 % 2 * Output: 1
  5. Input: 3 ! 4 5 * + Output: 26
  6. Input: 12 3 / ! Output: 24
  7. Input: 5 1 2 + 4 * + 3 - Output: 14

To run this program you've to install Eclipse IDE, Java7 or more and JUnit(Optional).

First Install Java Open Eclipse Import this project Find MainTest.class (shortcut - ctrl+shift+r) and run this file enter your input on console or you can pass parameter in test(input).