Write a command line calculator that supports exponentiation (^ symbol), multiplication, division, addition and subtraction.

PHASE 1

1. Write a program called "Calculator" that reads input from user as a string until the input is "exit". Use a prompt (examples: >> , --> ) for user input.

2. Split the string into an array of Strings (or "tokens").

3. Write a subroutine that takes a String and returns whether or not it is a valid Operand/number

4. Write a subroutine that takes a String and returns whether or not it is a valid Operator (valid operators are, in order of precedence, ^, *, /, +, - where '^' is exponentiation.

5. Write a subroutine that checks to see if the Array of Strings is a complete, valid expression.

PHASE 2

1. Complete NumberNode.java (write the constructors)

2. Complete OperatorNode.java (constructs, getters and setters)

3. Write OperatorNode's value() function. This is a big one!

PHASE 3

1. Write a subroutine in Calculator.java that accepts a String representing an operator and returns an integer representing its priority number. (use ArrayLists's indexOf() method).

2. Write a subroutine in Calculator.java that accepts the String array representing the whole expression, that will build an Expression Tree and return its root node. THE OTHER BIG ONE!

3. Finish Calculator.java. If the expression is valid (you wrote a subroutine for that), pass the expression String Array to the Expression Builder which will return the ENode root of the tree.

4. Get the value of the root ENode and print this to the screen as the final calculation.

5. Submit Calculator.java, NumberNode.java and OperatorNode.java

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.