CASE STUDY^507
public intnumOfMatches(AnswerSheet key)
// Return the number of matches between key and student
// answer
{
intnumCorrect = 0 ;
for(int counter = 0 ; counter < responses.length; counter++)
if(responses[counter] == key.responses[counter])
numCorrect++;
returnnumCorrect;
}
publicString knowName()
// Knowledge responsibility
{
returnname;
}
public booleanmoreData()
{
returnname != null;
}
}
//**
// This class is a driver that creates a key and a student
// answer sheet. The answer sheet is compared with the key
// and the number correct is printed following the name.
//**
importgrader.;
importjava.io.;
public classGradeExams
{
public static voidmain(String[] args) throwsIOException
{
BufferedReader inFile;
PrintWriter outFile;
inFile = newBufferedReader(newFileReader(“Exams”));
outFile = newPrintWriter(newFileWriter(“Results”));
AnswerSheet key;
AnswerSheet studentSheet;
intnumItems;
numItems = Integer.parseInt(inFile.readLine());