Assignment 121

Code

    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Scanner;
    
    class hi
    {
        public static void main (String [] args)
        {
            PrintWriter fileOut;
            Scanner kb = new Scanner(System.in);
            
            System.out.print("What is your high score: ");
            double score = kb.nextDouble();
            System.out.print("What is your name: ");
            String name = kb.next();
            
            try
            {
                fileOut = new PrintWriter("score.txt");
                
            } 
            catch(IOException e)
            {
                fileOut=null;
                System.exit(1);
            }
            
            fileOut.println("User " + name );
            fileOut.println("Score " + score);
            fileOut.close();
        }
    }
    

Picture of the output

Assignment