Computer Science 121
Assignment 2
Due: February 13, 2001

Your second assignment is to write a program that reads data from the keyboard into the program.  The data will be the name, memory size and speed of your computer. You should write a new method that will read this data.  This method should be in the class that describes the computer, not the main class.

The constructor for the computer class should just assign default values to the data, such as a zero to the memory size.  The actual initialization of the variables is done by the method that reads the data.

The new method should first prompt for and then read in the data.  Read each data item on a separate line.  You will need to use a buffered reader in order to read the data.  Refer to the third People example (on the other side of this sheet) for the way to declare it.  This example is also on the course website.

Hand in a print out of your program and a disk containing both the .java and the .class files.  In addition, write a separate paper that answers the questions given below.  Type your paper using an appropriate word processor, such as Word or WordPerfect.

Questions

1.    How did you choose the names (identifiers) that you used in your program?

2.    What would happen if you changed the order of some of the statements in the main method? For example, what would the output be if you tried to display the data before you read it in?

3.    Why do we need to use a buffered reader? What service does the buffer provide for the program?

4.    What is a number format exception? What input could cause the exception to occur?