Your Name  _____________Adams - KEY_________________________

 

Lab 5  : Experimenting with Input/Output

 

2.3. What was the first error generated by the compiler?

Ï «Ï ----jGRASP exec: javac -g -source 1.5 C:\Documents and Settings\liz\Desktop\Lab5\Rooter.java
ÏϧÏ
ϼ§ÏRooter.java:13: cannot find symbol
ÏϧÏsymbol  : class PrintWriter
ÏϧÏlocation: class Rooter
ÏϧϠ      PrintWriter     screen;      
ÏϧϠ      ^

 

2.4. What line did you need to add?

import java.io.PrintWriter;    OR   import java.io.*;

 

2.6. What was the first error generated by the compiler this time?

ÏRooter.java:14: cannot find symbol
ÏϧÏsymbol  : class Scanner
ÏϧÏlocation: class Rooter
ÏϧϠ      Scanner         keyboard;
ÏϧϠ      ^

 

2.7.  Fix this error.  What line did you need to add?

import java.util.Scanner;   or import java.util.*;

 

2.8. System.out is an object of which Java class?

  NOTava.Lang - it's a package  but  SYSTEM

 

3.4. Why was no output generated?

because PrintWriter writes to output stream (buffer) but doesn't include a newline so buffer is not dumped to the screen.  http://java.sun.com/j2se/1.5.0/docs/api/  

 

3.5. Fix this mistake.  What line did you add?

screen.flush();

 

3.6. What do you need to type in the terminal window (as a response to

the prompt) in order to make this application terminate normally?

<ctrl>-C     or  <ctrl>-Z

 

4.4. What output was generated?

Today's Date: 8 September 2008

        Birthday: Pink

 

4.7. What happened and why?

The system cannot find the file specified. 

because there was no file in the directory named Anniversaries.txt

4.9 What changes did you need to make?

  private static File             dates;

 

4.11 What did you need to add?

dates    = new File(args[0]);    

 

4.13. What changes did you need to make?

try
{
   dateScanner =
new Scanner (dates);

        // dates is a new file with name from args[0]   
}  // end try
catch (FileNotFoundException fnfe)
{
   System.out.println( fnfe.getMessage()); 
} 
// end catch

         

4.15. What output was generated?

Today's Date: 8 September 2008

        Birthday: Pink

 

5.2. What changes did you need to make?  See different versions of Remember in Lecture notes

  private static File           dates2;

  dates2   = new File(args[1]); 

    try
    {
        dateScanner =
new Scanner (dates2);

           // dates is a new file with name from args[1]   
    }  // end try
   catch (FileNotFoundException fnfe)
   {
      System.out.println( fnfe.getMessage());_ 
   } 
// end catch
    processDates(today); // processDates is a programmer defined method

         

5.4. What output was generated?

Today's Date: 8 September 2008

        Birthday: Pink

        Read Chapter 10 of War and Peace