Advanced Programming - CS239
Department of Computer Science
LAB 18: EXPERIMENTING WITH ARRAYS OF
ARRAYS
Getting Ready: Before
going any further you should:
1. Make a directory on your N: drive
for this lab.
2. Setup your development environment.
3. Copy the file named FieldFormat.java
4. Copy the file named TableWriter.java
5. Copy the file named Driver.java
Part I: This part
of the lab will help you understand arrays of arrays.
|
|
|
String[][] table = {
{"DJIA","10,487.11","+16.52","+0.16%"},
{"NASDAQ","2,060.94","+3.52","+0.18%"},
{"S&P
500","1,142.76","+0.95","+0.08%"},
{"10-Yr
TR.","4.20%","+0.06"}
};
|
|
|
Part II: This part
of the lab will help you get some experience writing code that uses arrays of
arrays.
|
2. Write a method public void printTableWithHeaders(String[][]
table) that prints row and column headers
(containing the index) along with the table. For example:
0 1 2
0 DJIA 678 Up
1 AMX 1021 Down
Attach your method
to your submission |
3. Write a method public void writeTable(String[][] table) that prints each element in the table preceeded by its
element reference (i.e., row,column) and a ":". It should print a
'\t' between elements and should not print the elements in a fixed-width
field (i.e., it should not use a FieldFormat object).
For example:
0,0:DJIA 0,1:678
0,2:Up
1,0:AMX 1,1:1021
1,2:Down
Attach your method to your submission. |