Assignemnt #121 and High Score

Code

/// Name: Raff Lisbona
/// Period: 6
/// Program Name: High Score
/// File Name: HighScore.java
/// Date Finished: 5/9/2016

import java.io.PrintWriter;
import java.io.IOException;
import java.util.Scanner;
public class HighScore
{
    public static void main( String[] args )
    {
        PrintWriter fileOut;
        
        try{
            fileOut = new PrintWriter("score.txt");
        }catch(IOException e) {
            System.out.println("Sorry, I can't open the file 'score.txt' for editing.");
            System.out.println("Maybe the file exists and is read-only?");
            fileOut = null;
            System.exit(1);
        }
        Scanner kb = new Scanner(System.in);
        
        System.out.println("You got a high score!!!");
        System.out.print("\nPlease enter your score: ");
        int score = kb.nextInt();
        System.out.print("Please enter your name: ");
        String name = kb.next();
        
        fileOut.println("+-------------------------+");
        fileOut.println("|                         |");
        fileOut.println("|    HIGHSCORES!          |");
        fileOut.println("|                         |");
        fileOut.println("|   1. " + name + " " + score + "        |");
        fileOut.println("|                         |");
        fileOut.println("+-------------------------+");
        
        System.out.println("Data stored into score.txt. Thank you play again!");
        
        fileOut.close();
    }
}
    

Picture of the output

Assignment 8 Assignment 8