/**
 * Takes a file of track-meet results and extracts results for
 * a given school. It assumes that the results are in a file
 * named results.txt, and that each line of the file looks like this:
 * 
 * athlete name,school name,even name,result
 */

import java.util.*;  // needed for Scanner
import java.io.*;    // needed for File

public class ExtractResults {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner console = new Scanner(System.in);
        
        System.out.print("School to extract: ");
        String targetSchool = console.nextLine();
        
        Scanner input = new Scanner(new File("results.txt"));
        boolean foundSchool = false;
        
        while (input.hasNextLine()) {
            String record = input.nextLine();
            String[] fields = record.split(",");
            
            if (fields[1].equals(targetSchool)) {
                System.out.print(fields[0] + ",");
                System.out.println(fields[2] + "," + fields[3]);
                foundSchool = true;
            } 
        }
        
        if (!foundSchool) {
            System.out.println(targetSchool + " is not in the file.");    
        }
    }               
}