Assignemnt #121

Code

          /// Name: Holden Ganch
          /// Period: 7
          /// Program Name:  Fourty first Program
          /// File Name: Using.java
          /// Date Finished: 11/3/2015


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

public class High {

    public static void main(String[] args) {

        PrintWriter fileOut;
        Scanner kb = 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.println("You got a high score!!!");
        System.out.print("Please enter your high score: ");
        int x = kb.nextInt();
        System.out.print("Please eter your name: ");
        String n = kb.next();
        System.out.println("Data stored into score.txt. Thank you for playing.");

        fileOut.println( "High score: " + x );
        fileOut.println( "Person who set it:" + n );
        
        

        fileOut.close();
    }
}



    

Picture of the output

Assignment 121