An Homage to the program that started a revolution

Prof. George Hu

CSC 143 Spring 2018

In 1943, the head of International Business Machines, Thomas Watson, foolishly predicted “I think there is a world market for maybe five computers”. Fast forward to 1977 when the head of Digital Equipment Corporation also foolishly predicted “There is no reason anyone would want a computer in their home”. Why were these industry leaders wrong? Just two years later a program called VisiCalc was released on the Apple computer and became the world’s first “killer app” selling over 700,000 copies in six years. In 1983, Lotus Development Corporation released a new spreadsheet called Lotus 1-2-3 which immediately became the IBM PC’s killer app, and in the process killed both VisiCalc and the Apple II as people bought computers to run 1-2-3. Excel was released for the Mac in 1985 but it would take until 1992 before Excel on Windows would surpass 1-2-3 in sales and never look back.

This assignment is mainly about LinkedLists, but it is also an homage to the application that really brought computers and to every business and eventually every home in the world. Spreadsheets demanded using LinkedLists because one of the main advantages of a spreadsheet was the ability to insert rows and columns anywhere on the spreadsheet. The first spreadsheets only had 256 rows and columns, but quickly expanded the 65,000. If you had to modify all 65,000 every time you wanted to insert a single row or column, it would be too slow. Another advantage is that most spreadsheets are basically empty except for a few areas. Linked lists are better than arrays because we can only allocate the cells that are actually being used. So from the very beginning, spreadsheets have been designed using LinkedLists.

Our Tiny123 application is the most primitive spreadsheet imaginable with no contents other than Strings and all cells allocated so we can just index into any row or column. For each row we will use a class called “SheetRow” made up of a LinkedList of String cells. We will initially construct a sheet of nine rows and columns, and allow insertion and deletion of rows and columns, setting the value of a particular cell, and summing each row & col. Each cell will contain initially a string in the form “R1C1” where 1 is replaced with whatever it’s row and column is. We won’t change this content when inserting or deleting, so the contents really reflect a cells initial location and not the current location. While writing your own spreadsheet certainly sounds intimidating, providing this very limited set of functions is not difficult, and the Java LinkedList does most of the work for us. Here are the two classes that you will need to implement.

class Sheet {
private LinkedList rows;

public Sheet(); // creates a 9×9 sheet of cells “R<1..9>C<1..9>” public void insertRow(int row); // inserts row at 0-based index public void deleteRow(int row); // deletes row at 0-based index

public void insertCol(int col); // inserts col at 0-based index “R…C” in each row public void deleteCol(int col); // deletes col at 0-based index in each row

public void setValue(int row, int col, String s); // sets String value public String toString();


class SheetRow {

private LinkedList cells;

public SheetRow(int row); // creates 9 column of cells “RC<1..9>” public void addCell(int index, String s); // adds 0-based col to this row public void removeCell(int index); // removes 0-based col from this row public void setValue(int cell, String s); // sets value at col public String toString();


To understand exactly how these work and the output format, please see the attached code for main() which you shouldn’t modify, and the output.txt file which you must match exactly. Use https://www.diffchecker.com/ to check it and take a screenshot of the success. Here’s a small sample:


SheetRow is a simple LinkedList of individual cells in a row and the add/remove/set functions can just call the similar LinkedList functions. The Constructor will need to add the nine columns labeled “R1C1”..”R1C9” replacing 1 with the argument. The toString needs to manually build the string for the row. To format cells to be the same width, use

String.format(“%-8s”, s)

Sheet is more complex since it includes a LinkedList of SheetRows. The Constructor can call the SheetRow() for each of the nine initial rows. InsertRow/deleteRow can just call the LinkedList functions. But the insertCol/deleteCol need to affect each row, so you must use the Iterator to get each SheetRow before calling addCol/removeCol. SetValue is very straightforward using the LinkedList functions to directly index into the correct row and then column.

The hardest part of this assignment is actually calculating the sums for each row and column. Ideally this would be done in a separate function and would involve adding a Sheet.Sum function and a SheetRow.getValue and Sheet.getValue method. But to keep it simple and efficient, do it inside the toString for the two classes. It is very easy to do for the SheetRow because you have to print everything in that row anyways so you have easy access. The calculation for the columns in the Sheet are harder. Each time you print a row you have to update a running total for each column. Even though it is not the most ideal data structure, please use one LinkedList to keep this running total. Use a scanner on the string of each cell to see if you can convert it to an integer, but make sure to call Scanner.close() because you are going to be opening hundreds of scanners and you don’t want to create a big memory leak.


There will be no pseudocode phase for this assignment because the initial code is actually very straightforward. Instead, I will separate out creating the sums for the rows and columns. You may skip directly to phase 2, but be sure to note that on your submission.

Phase 1 – Everything except printing the sums (match the output no sums.txt)

Phase 2 – Summing up the rows & columns. (match the output.txt)

What to Submit

Phase 1 & 2 – .JAVA, .JPG diff checker image (see sample diff checker output)