Prog 121: High Score
//Name: Ilana Levy
//Period: 5
//Program Name: High Score
//File Name: highScore.java
//Date Finished: 2/11/16
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class highScore
{
public static void main( String[] args)
{
PrintWriter fileOut;
Scanner scan = new Scanner( System.in);
try
{
fileOut = new PrintWriter("score.txt");
}
catch (IOException e)
{
System.out.println( "Sorry, there appears to be an error in opening score.txt");
fileOut = null;
System.exit(1);
}
System.out.println( "You got a high score !!!");
System.out.print( "Please enter your score: " );
int score = scan.nextInt();
System.out.print( "Please enter your name: " );
String name = scan.next();
fileOut.print( name + "\t" + score);
System.out.println("Data stored into score.txt. Thank you. Play again.");
fileOut.close();
}
}