Assignment #121

Code

      //jack newsom
//period 5
//program HighScore
//filename HighScore.java
//date completed 2/18/16


import java.io.PrintWriter;
import java.io.IOException;
import java.util.Scanner;


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

        try{
            fileOut = new PrintWriter("score.txt");

        } catch(IOException e) {
            System.out.println("Sorry, I can't open the file 'receipt.txt' for editing.");
            System.out.println("Maybe the file exists and is read-only?");
            fileOut = null;
            System.exit(1);
        }
        
        System.out.print("whats ya name? ");
        String name = bot.next();
        
        System.out.println("whats ya score? ");
        int score = bot.nextInt();
        
        fileOut.println(name);
        fileOut.println(score);

        
        fileOut.close();
    }
}
    

Picture of the output