I am trying to make the program access a file name "highscore.txt", then:
Write a new number in the file
Get the lowest value of a list of numbers in the file.
I am new to Java so I barely know how to even access the file.
I got code that I believe should work, but when I run the program it says
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:864)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextDouble(Scanner.java:2413)
at game.game.main(game.java:91)
Java Result: 1
Here is line 84 - 94, and the code I got.
84: Writer wr = new FileWriter("highscore.txt");
85: wr.write(tries);
86: wr.close();
87: lowest = tries;
88: File file = new File("highscore.txt");
89: Scanner inputFile = new Scanner(file);
90: while (inputFile.hasNext()) {
91: numb = inputFile.nextDouble();
92: if (numb < lowest) lowest = number;
93: }
94: inputFile.close();