Docsity

Spreadsheet Program Assignment, Assignments of Computer Science

Toggle sidebar
bg1
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.

Partial preview of the text

Download Spreadsheet Program Assignment and more Assignments Computer Science in PDF only on Docsity!

Program 2: Due 2/ 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, . 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)* 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.