import java.io.*; 
  
public class KeepingScore2 
{ 
  public static void main(String[] argv) throws Exception 
  { 
    // open scores.txt (see text section 10.2.2) 
    String scoreFile = "scores.txt"; 
    BufferedReader fin; 
    fin = new BufferedReader(new FileReader(scoreFile)); 

    // create a variable, read it from scores.txt (10.1.5) 
    int wins; 
    wins = new Double(fin.readLine()).intValue(); 
    System.out.println("You won " + wins + " time(s)."); 

    // create a variable, read it from scores.txt (10.1.5) 
    int losses; 
    losses = new Double(fin.readLine()).intValue(); 
    System.out.println("You lost " + losses + " time(s)."); 

    // close scores.txt (10.1.3) 
    fin.close(); 

    // play the game(s) in a loop here (MISSING)
    // ...for each win, do wins++; 
    // ...for each loss, do losses++; 
 
     // rewrite scores.txt with the latest scores 
    PrintWriter fout; 
    fout = new PrintWriter(new FileWriter(scoreFile)); 
    fout.println(wins); 
    fout.println(losses); 
    fout.close(); 
  } 
} 
