This assignment is due on Tuesday, 24 April, no later than 2:00 p.m.See the assignment turn-in page for instructions on turning in your assignment.
A spreadsheet is a matrix in which the rows are indexed by the letters "a" through "z" (case doesn't matter) and the columns are indexed by non-negative integers (a spreadsheet has 26 rows and an infinite number of columns. A cell reference is the catenation of a row and column index; for example, the cell in row A at column 10 has cell reference A10 (or a10).A cell is either empty or contains an expression of the form
value ( operation value )*where (a)* means zero or more occurrences of a. value is either an unsigned integer or a cell reference, and operation is one of the operations+
,-
,*
, or/
. Because there are no parenthesis, operations are evaluated in strict left-to-right order as they occur in an expression; for example, the expressionis evaluated as if it were parenthesized asf1 - 32/9*5(((f1 - 32)/9)*5)The result of evaluating an expression can be a floating point number.
Write a program that reads from std-in a description of a spreadsheet, carries out the computations described in the spreadsheet, and writes to std-out the values of the non-empty cells in the spreadsheet.
Input to the program is a sequence of zero or more blocks; each block is separated the next by at least one blank line. Blank lines may precede the first block and follow the last block.Each block consists of a sequence of one or more cell descriptions. A cell description is a line of the form
cell-referenceEach cell description occupies one line, and each line contains exactly one cell description.=
expressionThe following input example consists of three blocks:
f0 = c1*9/5 + 32 c0 = f1 - 32/9*5 c1 = 0 f1 = 32 c1 = 100 f1 = 212
After reading each block, your program should output the values of the non-empty cells in the spreadsheet. Whenever possible, expressions should be reduced to numbers before printing; if an expression can't be reduced to a number, your program should print the expression. Your program should produce output after reading each block.The output produced by your program should follow the input format: a sequence of cell definitions, one per line; each sequence is separated from the next by a blank line.
The following output example shows what your program should produce if given the input example in the previous section.
f0 = c1*9/5 + 32 c0 = f1 - 32/9*5 c0 = 0 c1 = 0 f0 = 32 f1 = 32 c0 = 100 c1 = 100 f0 = 212 f1 = 212
No test files; you're on your own.
This page last modified on 10 April 2001.