Im surprised that would compile!
You probably want
int rebounds = scanner.nextInt(); or something along those lines.
So after you have your 3 variables for instance:
int points;
int rebounds,
int layups;
You could do the following to output it to a .txt or .csv file:
Code:
public void writeFile(String filename,int points, int rebounds, int layups){
try{
// Create file
FileWriter fstream = new FileWriter(filename);
BufferedWriter out = new BufferedWriter(fstream);
out.write("Points,"+points+",rebounds,"+rebounds+"layups,"+layups);
//Close the output stream
out.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}
You could then call it from the bottom of your code by doing :
Code:
writeFile("myStatsFileToday.txt",points,rebounds,layups);
Bare in mind the file would then be written to the directory where your program is running - if you wanted a different output directory you just append that to the filename i.e
Code:
writeFile("C:\\mystats\\myStatsFileToday.txt",points,rebounds,layups);
double \\ are needed because you need to escape the "\". You may also want to append to a single file so you can use the same program to add to a single file to build a record of your stats - but thats your own little addition if you wanted it