import java.io.*;
/**
 * Stores Test 1 scores in Test1Scores file  
 * appending new values to existing file
 * @author Suzanne Balik, 29 Mar 2003
 */
 public class TestScores {
 
   public static void main(String[] args) {
   
     try {
     
       BufferedReader br = new BufferedReader
                           (new InputStreamReader(System.in));
	
       //Open Test1Scores file for "append"		   
       PrintWriter pw = new PrintWriter(new FileWriter
                        ("Test1Scores", true));
       int score = 0;		
       do {
         
	 String line;
         System.out.print("Enter test score (-1 to quit): ");
	 System.out.flush();
	 line = br.readLine();
	 try {
	   //Make sure test score is an integer value!!
	   score = Integer.parseInt(line);
	   if (score != -1)
	     pw.println(score);
	 }
	 catch (NumberFormatException e) {
	   System.out.println("INVALID SCORE");
	 }
       } while (score != -1);
       
      pw.close();
    }
    catch (IOException e) {
      System.err.println(e);
      System.exit(1);
    }
  }
}       











/* PROGRAM OUTPUT:

csc% java TestScores
Enter test score (-1 to quit): 89
Enter test score (-1 to quit): 78
Enter test score (-1 to quit): 90
Enter test score (-1 to quit): 34
Enter test score (-1 to quit): 78
Enter test score (-1 to quit): -1
csc% cat Test1Scores 
89
78
90
34
78
csc% java TestScores
Enter test score (-1 to quit): 56
Enter test score (-1 to quit): 89
Enter test score (-1 to quit): 90
Enter test score (-1 to quit): -1
csc% cat Test1Scores 
89
78
90
34
78
56
89
90
*/