Project 2, CSC 2001
1 Calculator
9.3

Project 2, CSC 2001🔗

1 Calculator🔗

In this assignment, you will implement a simple "calculator"; it will take in strings that represent expressions in an arithmetic language, and return the number that the expression computes.

So, for instance, given the expression "3 + 4 ^ 2", your calculator will produce 19.

This process will require a few passes; the first pass, "tokenization", simply splits up the string into a list of "words"; for our calculator, we will insist on a space between every adjacent pair of tokens, so we can accomplish this tokenization step by using Java’s ‘String.split‘ method as described in the associated document.

The next pass, "parsing", will take this sequence of tokens and construct an "expression" tree. Again, this is described in the attached document.

Finally, the "eval" method on expressions will evaluate the resulting tree. This pass is also described in the attached document.

Man, that attached document sounds pretty good! Let’s have a link to it:

ATTACHED DOCUMENT

Neat!