//File:	TestingFile.java
import CSLib.*;
import java.io.*;
import java.util.StringTokenizer;
public class TestingFile
{
	public static void main (String [] args)
	{
		String [] id = new String [100];
		int [] correct = new int [100];
		
		int k=0; //k counts up how many students there are
		try
		{	
			//Step 1.  file (stream of bytes)
			String filename = "test.txt";
			
			//Step 2.  FileReader object (stream of chars)
			FileReader fr = new FileReader(filename); //throws FileNotFoundException
			
			//Step 3.  BufferedReader object (buffers input allowing access from RAM instead of file)
			BufferedReader br = new BufferedReader (fr);
		
			//Step 4.  readLine() message to Buffered Reader object returns String reference to first line of input
			String key = br.readLine(); //throws IOException
				
			String line = br.readLine(); //throws IOException
			while (line != null)
			{
				//Step 5.  StringTokenizer object divides line of data from step 4 into distinct data items
				StringTokenizer tokenizer = new StringTokenizer(line);
				id [k] = tokenizer.nextToken();	
				String answer = tokenizer.nextToken();
			
				for (int i=0; i<10; i++)
				{
					if (answer.charAt(i) == key.charAt(i))
						correct[k]++;
				}
			
				k++;
				line = br.readLine(); //throws IOException
			}
			br.close(); //close the stream
		}
		catch (FileNotFoundException e)
		{
			System.out.println(e.getMessage());
		}
		catch (IOException e)
		{
		}
		
		//int avg = NumberList.average(list);
		
		OutputBox out = new OutputBox();
		out.setSize(450, 300);
		out.println ("Student Identification\tNumber of Correct Answers");
		for (int i=0; i<53; i++)
		{
			out.print ("-");
		}
		out.println();
				
		for (int j=0; j<k; j++)
		{
			out.println ("\t" + id[j] + "\t\t\t\t\t" + correct[j]);
		}
	}
}
