=========================================================
=  Simple 6-Function Calculator / Expression Evaluator  =
=========================================================
 
Author:  Pollack, Bary W   - ID 1234 - Section 001
Author:  Skywalker, Anakin - ID 5678 - Section 001
Date:    February 10, 2001
Course:  CIS 110L - Data Structures & Algorithms - Assignment L2
 
This program reads a sequence of lines, each containing a valid
arithmetic expression.  Each expression is evaluated.  The
Calculator supports + - * / ^ =.  Variables have initial value
zero.  Their subsequent values are as calculated and assigned.
Input is assumed to come from file 'CalcData.txt' which should
reside in the current directory.  At the end of execution the
contents of the Symbol Table are displayed.
 
Evaluation proceeds in two steps:
 
1. Translate each infix expression into postfix, printing the
   resulting expression.  Use the Railway Shunt Algorithm for
   infix -> postfix.
 
2. Evaluate the postfix expression, printing the final result.
   Use direct evaluation to accomplish this.
 
Translation and Evaluation Begins...
 
Expression #1
Input:     easy = 1
Postfix:   easy 1 = | 
Value:     1

Expression #2
Input:     CIS110LHomeworkAssignmentL2 = easy
Postfix:   CIS110LHomeworkAssignmentL2 easy = | 
Value:     1

Expression #3
Input:      
Postfix:   | 
Value:     0

Expression #4
Input:     123.0
Postfix:   123 | 
Value:     123

Expression #5
Input:     0.25E+17
Postfix:   24999999607668736 | 
Value:     24999999607668736

Expression #6
Input:     2+3+4+5E0
Postfix:   2 3 + 4 + 5 + | 
Value:     14

Expression #7
Input:     3+4*5
Postfix:   3 4 5 * + | 
Value:     23

Expression #8
Input:     9/3 - 5/2
Postfix:   9 3 / 5 2 / - | 
Value:     0.5

Expression #9
Input:     10*9*8*7*6*5*4*3*2*1
Postfix:   10 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 * | 
Value:     3628800

Expression #10
Input:     10/9/8/7/6/5/4/3/2/1
Postfix:   10 9 / 8 / 7 / 6 / 5 / 4 / 3 / 2 / 1 / | 
Value:     2.7557318E-5

Expression #11
Input:     2*2*2*2*2*2*2*2*2*2*2
Postfix:   2 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * | 
Value:     2048

Expression #12
Input:     3.0*3.0*3.0*3.0*3.0*3.0*3.0*3.0*3.0*3.0
Postfix:   3 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * | 
Value:     59049

Expression #13
Input:     32768/65536*4
Postfix:   32768 65536 / 4 * | 
Value:     2

Expression #14
Input:     65536/32768/4
Postfix:   65536 32768 / 4 / | 
Value:     0.5

Expression #15
Input:     1 + 1/10 + 1/100 + 1/1000 + 1/10000
Postfix:   1 1 10 / + 1 100 / + 1 1000 / + 1 10000 / + | 
Value:     1.1111

Expression #16
Input:     1 + 1e-1 + 1E-2 + 1e-03 + 1.0E-04
Postfix:   1 0.1 + 0.01 + 0.0010 + 1.0E-4 + | 
Value:     1.1111

Expression #17
Input:     1/9*5 + 5/9
Postfix:   1 9 / 5 * 5 9 / + | 
Value:     1.1111112

Expression #18
Input:      
Postfix:   | 
Value:     0

Expression #19
Input:     2^0
Postfix:   2 0 ^ | 
Value:     1

Expression #20
Input:     4^3^2
Postfix:   4 3 2 ^ ^ | 
Value:     262144

Expression #21
Input:     9/0
Postfix:   9 0 / | 
Value:     0

Expression #22
Input:     0^0
Postfix:   0 0 ^ | 
Value:     1

Expression #23
Input:     0^0/0^0
Postfix:   0 0 ^ 0 0 ^ / | 
Value:     1

Expression #24
Input:     3*(5-2*2^3)*9
Postfix:   3 5 2 2 3 ^ * - * 9 * | 
Value:     -297

Expression #25
Input:     3*(5-2*2^3)*9^2
Postfix:   3 5 2 2 3 ^ * - * 9 2 ^ * | 
Value:     -2673

Expression #26
Input:     (3 * (5 - 2*2^3) * 9^ (2-3))
Postfix:   3 5 2 2 3 ^ * - * 9 2 3 - ^ * | 
Value:     -3.6666667

Expression #27
Input:     3 * (5 - 2*2^3) * 9^ (2-3.5^3)
Postfix:   3 5 2 2 3 ^ * - * 9 2 3.5 3 ^ - ^ * | 
Value:     -3.2647609E-38

Expression #28
Input:     777.777 / 1.777 ^ 1.777 ^ 1.777 ^ 1.777 ^ 1.777
Postfix:   777.777 1.777 1.777 1.777 1.777 1.777 ^ ^ ^ ^ / | 
Value:     0.041784935

Expression #29
Input:     (7654.321 / (2 * 3.35 - 4.5) * (7 / 3 * 2) / (5.5 ^ 2 * 3) ^ 3.5)
Postfix:   7654.321 2 3.35 * 4.5 - / 7 3 / 2 * * 5.5 2 ^ 3 * 3.5 ^ / | 
Value:     0.0022804867

Expression #30
Input:      
Postfix:   | 
Value:     0

Expression #31
Input:     a = 1
Postfix:   a 1 = | 
Value:     1

Expression #32
Input:     b = a + a
Postfix:   b a a + = | 
Value:     2

Expression #33
Input:     c = b^2 - 0^0
Postfix:   c b 2 ^ 0 0 ^ - = | 
Value:     3

Expression #34
Input:     d = 99
Postfix:   d 99 = | 
Value:     99

Expression #35
Input:     d = 10 ^ d / 10^(d + 2) * 7
Postfix:   d 10 d ^ 10 d 2 + ^ / 7 * = | 
Value:     0.07

Expression #36
Input:     e = d + 1e00+d-d+2e-01
Postfix:   e d 1 + d + d - 0.2 + = | 
Value:     1.27

Expression #37
Input:     george = (able = (baker = d + 1) * 2) ^ 3
Postfix:   george able baker d 1 + = 2 * = 3 ^ = | 
Value:     9.800344

Expression #38
Input:     George = george / (baker + 3.5) / 5 ^ 5
Postfix:   George george baker 3.5 + / 5 5 ^ / = | 
Value:     6.862385E-4

Expression #39
Input:     george
Postfix:   george | 
Value:     9.800344

Expression #40
Input:     (grandfather99 = grandmother99 = (george + 25.0)) / 3
Postfix:   grandfather99 grandmother99 george 25 + = = 3 / | 
Value:     11.600115

Expression #41
Input:     grandmother99 = 1.5 / grandmother99 ^ (c + 2^3)
Postfix:   grandmother99 1.5 grandmother99 c 2 3 ^ + ^ / = | 
Value:     1.6545212E-17

Expression #42
Input:     grandson = 1e10*grandmother99*1.E10
Postfix:   grandson 10000000000 grandmother99 * 10000000000 * = | 
Value:     1654.5212

Expression #43
Input:     English = easy * 10^9 / 9^10
Postfix:   English easy 10 9 ^ * 9 10 ^ / = | 
Value:     0.2867972

Expression #44
Input:     in = 10
Postfix:   in 10 = | 
Value:     10

Expression #45
Input:     word = 100.1
Postfix:   word 100.1 = | 
Value:     100.1

Expression #46
Input:     nontechnical = (((1000.01)))
Postfix:   nontechnical 1000.01 = | 
Value:     1000.01

Expression #47
Input:     (((longest = word ^ 2)))
Postfix:   longest word 2 ^ = | 
Value:     10020.01

Expression #48
Input:     the = 10 * (longest)
Postfix:   the 10 longest * = | 
Value:     100200.1

Expression #49
Input:     is = (the) / (0.1)
Postfix:   is the 0.1 / = | 
Value:     1002001

Expression #50
Input:     antidisestablishmentarianism = is + the + longest + nontechnical + word + in + English
Postfix:   antidisestablishmentarianism is the + longest + nontechnical + word + in + English + = | 
Value:     1113331.5

Final Values (22 variables)

    1    a                              1
    2    able                           2.14
    3    antidisestablishmentarianism   1113331.5
    4    b                              2
    5    baker                          1.07
    6    c                              3
    7    CIS110LHomeworkAssignmentL2    1
    8    d                              0.07
    9    e                              1.27
    10   easy                           1
    11   English                        0.2867972
    12   george                         9.800344
    13   George                         6.862385E-4
    14   grandfather99                  34.800343
    15   grandmother99                  1.6545212E-17
    16   grandson                       1654.5212
    17   in                             10
    18   is                             1002001
    19   longest                        10020.01
    20   nontechnical                   1000.01
    21   the                            100200.1
    22   word                           100.1

* Fini! *

