Problem S. 39. (November 2008)
S. 39. Write a program that implements a calculator. The calculator should be able to evaluate expressions containing the four basic arithmetic operations (+,,*,/), integers and parentheses. Operations should have the usual precedence: multiplication and division have the same priority, further, addition and subtraction have the same priority, but multiplication and division are evaluated first. If there are no parentheses, and several operations of the same precedence are present, evaluation is performed from left to right, for example efa/b/c*d=(ef)(((a/b)/c)*d).
The expressions to be evaluated are found in the input file, whose name is the first command line argument of your program, while results are written into the output file, whose name is the second command line argument. Each line of the input file contains an expression. The corresponding single line in the output file should contain the evaluation of this expression: the exact result should be given as a fraction or integer in its simplest form. Issue a warning of ``Division by 0'' when necessary.
The length of each input line is at most 250 characters and each expression is syntactically correct. You can further assume that during the computations each intermediate result (in its simplest form) can be represented as a ratio of 16bit integers. (However, temporarily it may be necessary to use 32bit integers to avoid overflow.)
In the example, ``Példabemenet'' is the input, ``Példakimenet'' is the corresponding output, while ``Nullával osztás'' is division by 0.
The source code of your program (s39.pas, s39.cpp, ...) together with a short documentation (s39.txt, s39.pdf, ...) should be submitted, also containing a brief description of your solution and the name of the developer environment to use for compiling.
(10 pont)
Deadline expired on 15 December 2008.
Statistics:
