I'm trying to ask the user to enter 7 scores by writetofile method by a loop that get written on a file on a separate line.
This is what I have so far:
On this line, while !(Num < 0) { the error is '(' expected...how do I fix this?public static void main(String[] args) throws IOException { writeToFile ("c:\\scores.txt"); } public static void writeToFile (String filename) throws IOException { BufferedWriter outputWriter = new BufferedWriter(new FileWriter(filename)); Scanner reader = new Scanner (System.in); int Num; System.out.println ("Please enter 7 scores"); Num= reader.nextInt (); while !(Num < 0) { for (int i = 0; i <= 7; i++) Num= reader.nextInt (); outputWriter.write(Num); outputWriter.newLine(); } outputWriter.flush(); outputWriter.close(); }
Also, the when I run the program, it asks for 7 scores, but it just keeps going with the user typing integers. Also, the file gets cleared and no scores show up there.