X477: evaluator

Given a stack with Integers, write a function that pops the top two numbers from the stack, adds them together and pushes the result back on the stack. Continue doing this until the stack has only 1 value left (i.e. size of the stack is 1). When only 1 integer is left, pop that value and return that number. This should work for a stack with any number of values. If the stack is empty, simply return 0.

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.