
Program 2: Due 2/12
Create a simple spreadsheet program. Your spreadsheet will be 4 rows by 4 columns. Each row
is labeled with a number. Each column is labeled with a letter. The intersection of a row and a
column is a cell. Each cell has an address, <column><row>. Thus, the upper left cell is โA0โ and
the lower right cell is โD3โ.
A cell may contain a numeric constant, a string constant, or a formula. In this assignment, you
will display the value of each cell. The value of a constant is the constant. The value of a formula
is the value obtained by evaluating the formula.
Formulas begin with the โ=โ symbol. They contain the standard mathematical operators for
addition, subtraction, multiplication, division, exponentiation (โ^โ), and three named functions:
sine, cosine, and square root (โsinโ, โcosโ, and โsqrtโ, respectively). Input formulas also use
parentheses to enforce precedence. Formulas may contain constants, which are either integers or
floating point numbers, or they may contain cell references. An example of a formula is:
= B2 * 6 + (A1/A0)*2
In this formula, B2, A1, and A0 refer to the values contained in the referenced cells. The value of
a formula that has an error in evaluation (e.g., division by zero, square root of a negative number,
or numeric operation on a string) is the string โERRโ.
Your program needs a simple command line user interface to run. Do not build a GUI for this
program. You should allow the user to update the value of cells by entering the cell address and
the value, for example:
A2: 24
B3: =A2 + 1
After each entry, compute the current value of cells by evaluating each cell working across the
spreadsheet left-to-right, top-to-bottom.