Electrical & Computer Engineering Department, University of Maryland, College Park
Dr. Gang Qu
Project 2: Integer Arithmetic Expression Evaluator
Posted: Sunday, April 4
Due: Wednesday 11:59 pm, April 21 (no extension)
get familiar with the process of completing a programming project.
learn to use and manipulate arrays.
understand precedence and associative rules.
use program selection:
use basic loops (
) for repetition.
command line argument
read from and write into a file
In this project, you will design and implement a program to evaluate an arithmetic
expression. The arithmetic expression will contain only integers, both positive and negative, and
the five basic binary operators (+, -, %, /, *).
Your program should read in the expression from an input file. The input file has a
specific format, which is described below. After reading the expression, you are first going to
evaluate all the unary signs in the expression, next you will evaluate the *, /, % operators, and
finally the binary + and – operators. You will output the initial expression, intermediate steps,
and the final solution to an output file as well as the monitor. A master program, in the format of
executable file, and a sample input file will be provided.
Your program will read in input from a file of multiple lines. Each line represents exactly
one arithmetic expression. The first number of a line is the number of operands in the expression
). It is followed by
operands of integer values, and then
that represent the operators of the expression. All the numbers and characters are separated by a
single space, and there are no superfluous spaces at the end of each line. Each operator will be
placed between 2 consecutive operands to form the arithmetic operation. As an example, the