Assignment 121, HighScore
Code
///Name: Stella Koliavas
///Period: 5
///Program Name: High
///File Name: High.java
///Date Finshed: 6/03/16
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class High {
public static void main(String[] args) {
PrintWriter fileOut;
Scanner siri = new Scanner(System.in);
try{
fileOut = new PrintWriter("score.txt");
} catch(IOException e) {
System.out.println("Sorry, I can't open the file 'score.txt' for editing.");
System.out.println("Maybe the file exists and is read-only?");
fileOut = null;
System.exit(1);
}
System.out.print("Please enter your name: ");
String name = siri.next();
System.out.print("Please enter your score: ");
Double score = siri.nextDouble();
fileOut.println(name);
fileOut.println(score);
fileOut.close();
}
}
Picture of the output