I have specific instructions for this program and I keep getting this statemen'Exception in thread "main" java.io.FileNotFoundException: Game.txt (The system cannot find the file specified) at java.io.FileInputStream.open0(Native Method).' Below I will attach my program but can someone please explain this in the simplest terms. It also won't repeat the process even if I enter yes so any comments will benefit but please keep it in the simplest terms!`
int win;
int totalComp = 0;
int totalUser = 0;
String replay;
String rematch;
String gameFile = "Game.txt";
File file = new File(gameFile);
Scanner inputFile = new Scanner(file);
if (!file.exists())
{
FileWriter fw = new FileWriter (gameFile, true); //create file if doesn't exist
System.out.println("Welcome to the game of rock, paper, scissors!");
}
else
{
replay = inputFile.nextLine();
System.out.println("Welcome back! The score from last time was " + replay);
inputFile.close(); //close the file
}
do
{
computer = compChoice(); //call to computer choice method
user = userChoice(); // call to user choice method
win = winner(computer, user); // call to winner method
if (win == 1)
totalComp += 1;
else if (win == 2)
totalUser += 1;
System.out.println("The total score is User: " + totalUser + " and Computer: " + totalComp);
Scanner keybd = new Scanner(System.in);
System.out.println("Would you like to play again? Enter yes or no: ");
rematch = keybd.nextLine();
}while (rematch.equalsIgnoreCase("y"));
System.out.println("Good game! Goodbye."); //last statement
PrintWriter outputFile = new PrintWriter(gameFile); //open new or existing file
outputFile.println("User: " + totalUser + " Computer: " + totalComp);
outputFile.close(); //close file`