weekly_programmer

For Weekly Programming Challenges


Project maintained by AccaliaDeElementia Hosted on GitHub Pages — Theme by mattgraham

Weekly Programmer - Week 5

From Weekly Programmer Challenges

Description

Write a program that acts as a four function calculator that receives its input in Reverse Polish Notation

Formal Inputs & Outputs

Input Description

Valid inputs consist of the following tokens, each separated from the next token by whitespace:

For example:

15 7 1 1 + − / 3 × 2 1 1 + + − =

Output description

The result of the calculation, or if the stack is malformed an error message indicating what token was found and what class of token was expected.

From the above example the program should output the following:

5

Challenge Inputs

15 7 1 1 + − / 3 × 2 1 1 + + − =
.333 .333 .333 + + =
.1 .1 + .1 + =
2 2 * 5 5 * =
+ =
1   1   1   1   1   1   1   1   1   1
+ + + + + + + + + =