Assignemnt #121 High Score

Code

    ///Name: Joshua Pell
    ///Period: 6
    ///Project Name: High Score
    ///File Name: highScore.java
    ///Date: 5/31/2015
    
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

 public class highScore
 {
    public static void main( String[] args)
    {
         PrintWriter fileOut;
         Scanner scan = new Scanner( System.in);

        try
        {
           fileOut = new PrintWriter("score.txt");
        }
        catch (IOException e)
        {
            System.out.println( "Sorry, there appears to be an error in opening score.txt");
            fileOut = null;
            System.exit(1);
        }
            
            System.out.println( "You got a high score !!!");
            System.out.print( "Please enter your score: " );
            int score = scan.nextInt();
            System.out.print( "Please enter your name: " );
            String name = scan.next();
            fileOut.print( name + "\t" + score);
            System.out.println("Data stored into score.txt. Thank you. Play again.");
            
        fileOut.close();
    }
}
    

Picture of the output

Assignment 121