Assignment 2

Objectives:
To get an idea of practical C usage, including:

Supplemental:
To get a feel for Makefiles.

Due date:
02/08/01

Description:
  1. Design a simple calculator program to evaluate simple mathematical expressions, e.g., 2 * 4 + 3.
  2. Use string processing operations to parse the character string input (you'll need to distinguish between numerical values and mathematical operators such as ^, *, /, +, -).
  3. Use the stack ADT to:
    1. convert the infix expression into postfix (reverse Polish notation)
    2. evluate the postfix expression
  4. Break up your main program file into 4 modules: main.c, stk.c, mystring.c, cal.c, with their corresponding .h header files.
  5. Create a Makefile for your project.
  6. Sample output:
    	1 - 2 - 3 * 4 ^ 5 * 6 / 7 ^ 2 ^ 2
    	infix: 1 - 2 - 3 * 4 ^ 5 * 6 / 7 ^ 2 ^ 2
    	postfix: 1  2  -  3  4  5  ^  *  6  *  7  2  2 ^  ^  /  -
    	-8.677
    	2 * 4 + 3
    	infix: 2 * 4 + 3
    	postfix: 2  4  *  3 +
    	11.000
    	4 + 3 * 2
    	infix: 4 + 3 * 2
    	postfix: 4  3  2 *  +
    	10.000
    	2 * (3 + 4)
    	infix: 2 * (3 + 4)
    	postfix: 2  3  4 +  * 
    	14.000
    	(3 + 4) * 2
    	infix: (3 + 4) * 2
    	postfix: 3  4 +   2 * 
    	14.000
    	2 ^ 3 ^ 3
    	infix: 2 ^ 3 ^ 3
    	postfix: 2  3  3 ^  ^
    	134217728.000
    	3 * 2 ^ 5 - 1
    	infix: 3 * 2 ^ 5 - 1
    	postfix: 3  2  5  ^  *  1 -
    	95.000
    	1 + 2 * 3 ^ 4
    	infix: 1 + 2 * 3 ^ 4
    	postfix: 1  2  3  4 ^  *  +
    	163.000
    	2 ^ 5 - 1
    	infix: 2 ^ 5 - 1
    	postfix: 2  5  ^  1 -
    	31.000
    	q
    	

Notes, suggestions, warnings, and additional requirements:

What to hand in:
``Professional-quality'' code distribution file, including student identification in a README plain text file:
Course Id--Section No.
Name:
SS No:
Assignment No.

Electronic submission of source code: provide a self-contained, gzipped .tar of your project 1 directory, complete with a Makefile and README files. See the tar'ing instructions web page for further info on creating the tar file.
Your code MUST compile and run on a SUN machine.