Extra Credit Assignment 1 (25 Points) - Due M October 24, 11:59PM

Announcements and Clarification

October 11: Late assignments will be NOT be accepted for Extra Credit Assignments.

Postfix Expression Calculator

Create a calculon program capable of parsing a postfix algebraic expression from an input file, evaluating the expression, and displaying the result.

Commandline Arguments

Your program must be capable of utilizing a commandline argument to specify the input file.

calculon inputFile


Your program must ensure the user has correctly provided the required commandline argument and display a usage statement if the provided arguments are incorrect.

Input Postfix (RPN) Algebraic Expression File

The input file should specify a single algebraic expression in postfix order supporting positive and negative floating point values and the following operations: Addition (+), Subtraction (-), Multiplication (*), Division (/). All floating point value and operations should be whitespace delimited.

The following provides an example of the input of a postfix algebraic expression.

4 5 + 20 3 - * -4.0 +

Your program should report any errors that do not match the required input expression format and terminate execution.

Output Result of Algebraic Expression

The program should evaluate the algebraic expression and display the result. The following is an example of the desired program output:

4 5 + 20 3 - * -4.0 + = 149

Hint: You can use a stack (which is an abstraction of a doubly-linked list) to efficiently evaluate the expression.