Assignemnt #121: HighScore

Code

    /// Name: Kelsey Lieberman
    /// Period 5
    /// Program Name: HighScore
    /// File Name: HighScore.java
    /// Date Finished: 2/19/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("It didn't work.");
            fileOut = null;
            System.exit(1);
        }
        
        Scanner keyboard = new Scanner(System.in);
        
        double score;
        String name;
        
        System.out.print("You got a high score!!!\n\nPlease Enter Your Score: ");
        score = keyboard.nextDouble();
        System.out.print("Please Enter Your Name: ");
        name = keyboard.next();
        
        System.out.println("Data stored into score.txt. Thank you play again.");
        
        fileOut.println( "High Score!\n The score was: " + score + " and it was set by " + name + "!" );
        
        fileOut.close();
    }
}
    

Picture of the output

Assignment 121