Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Tiny123 An Homage to the program that started a revolution Prof. George Hu CSC 143 Spring 2018 In 1943, the head of International Business Machines,

image text in transcribed

image text in transcribed

Tiny123 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 worlds 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 PCs 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 its row and column is. We wont 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 9x9 sheet of cells RC 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 RC 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 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 shouldnt 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. Heres a small sample: Initial State R1C1 R1C2 R1C3 R1C4 R1C5 R1C6 R1C7 R1C8 R1C9 Sum = 0 R2C1 R2C2 R2C3 R2C4 R2C5 R2C6 R2C7 R2C8 R2C9 Sum = 0 R3C1 R3C2 R3C3 R3C4 R3C5 R3C6 R3C7 R3C8 R3C9 Sum = 0 R4C1 R4C2 R4C3 R4C4 R4C5 R4C6 R4C7 R4C8 R4C9 Sum = 0 R5C1 R5C2 R5C3 R5C4 R5C5 R5C6 R5C7 R5C8 R5C9 Sum = 0 R6C1 R6C2 R6C3 R6C4 R6C5 R6C6 R6C7 R6C8 R6C9 Sum = 0 R7C1 R7C2 R7C3 R7C4 R7C5 R7C6 R7C7 R7C8 R7C9 Sum = 0 R8C1 R8C2 R8C3 R8C4 R8C5 R8C6 R8C7 R8C8 R8C9 Sum = 0 R9C1 R9C2 R9C3 R9C4 R9C5 R9C6 R9C7 R9C8 R9C9 Sum = 0 Sum=0 Sum=0 Sum=0 Sum=0 Sum=0 Sum=0 Sum=0 Sum=0 Sum=0 Sum=0 Fill 3x3 array R0C0 R0C1 R0C2 R0C3 R0C4 R0C5 R0C7 R0C8 R0C9 Sum = 0 R1C0 1 2 3 R1C4 R1C5 R1C7 R1C8 R1C9 Sum = 6 R2C0 4 5 6 R2C4 R2C5 R2C7 R2C8 R2C9 Sum = 15 R3C0 7 8 9 R3C4 R3C5 R3C7 R3C8 R3C9 Sum = 24 R4C0 R4C1 R4C2 R4C3 R4C4 R4C5 R4C7 R4C8 R4C9 Sum = 0 R5C0 R5C1 R5C2 R5C3 R5C4 R5C5 R5C7 R5C8 R5C9 Sum = 0 R6C0 R6C1 R6C2 R6C3 R6C4 R6C5 R6C7 R6C8 R6C9 Sum = 0 R7C0 R7C1 R7C2 R7C3 R7C4 R7C5 R7C7 R7C8 R7C9 Sum = 0 R8C0 R9C1 R9C2 R9C3 R9C4 R9C5 R9C7 R9C8 R9C9 Sum = 0 Sum=0 Sum=12 Sum=15 Sum=18 Sum=0 Sum=0 Sum=0 Sum=0 Sum=0 Sum=0 Design 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 dont want to create a big memory leak. Phases 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 s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 R4C8 R5C8 R6C8 R7C8 R4C1 R4C2 R4C7 R4C9 R5C9 R6C9 R7C9 R6C0 R7C0 R6C3 R7C3 R8C0 R9C1 R10C2 R9C2 R10C4 R9C3 R9C4R9C5 R9C7 R9C8 R9C9 R6C7 R7C7 R6C1 R6C2 R7C2 Delete Row 10-6, Col 10-6 ROC0 ROC1 R0C2 ROC2 ROC4 RC3 R1C0 R2C1 R2C2 R2C2 R2C3 R2C4 R2C4 R2C0 R4C1 R4C2 R4C2 R4C3 R4C4 R4C4 R1C2 R1C4 3 R3C2 R3C4 Delete Row 0x6, Col 0x6

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

Evaluate the integral. cos' a sin a da

Answered: 1 week ago