6 Years
Discussion Span
Last Post by jon.kiparsky
for (int i = 0; i < 20; i++){
    	key[i] = (inFile.next().charAt(0) == 'T');
    for(int i=0; i<20; i++)

First of all, the second loop overwrites the first. Get rid of it. Next thing, each time you call inFile.next() it gets the next string of characters. You want to go through one set before you move on, so put the result of inFile.next() into a String and work on that String rather than calling next() again.
Your method of reading the key is correct, but maybe more complex than you need. You're asking, is the next character in the String a 'T'? That question returns a boolean, so you're storing a notional "True" or "False" - not the words, just the idea - into a place in an array. Later on, you'll have to do a similar conversion for the student answers.
However, since the student answers and the key are given to you in the same format, it would be simpler to simply compare them directly and operate on the results of the comparison.
There are three possibilities for each student answer, which can be checked using character comparison:
-is this a " "? if so, skip it.
-is it the same as the key? Give the student a point.
-if not, it's wrong, dock the student a point.
There's no need to convert the values to booleans, although your first loop is a good way of doing that.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.