Assignemnt #121 Data From A File

Code

     /// Name: Drew Boxold
    /// Period: 5
    /// Program Name: Data From a File
    /// File Name: DataFromAFile.java
    /// Date Finished: 5/30/16
    
    import java.io.PrintWriter;
import java.io.IOException;
import java.util.Scanner;

public class DataFromAFile
{
    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 41 Assignment 41