Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# using file.io


//Read the first line of text
string line = sr.ReadLine();
// Correct answers
string [] answerKey = line.Split();
while (true)
{
    line = sr.ReadLine();
    tokens = line.Split();
    id = Convert.ToInt32(tokens[0]);
    if (id == 0) break;
    string [] studentAnswers = tokens[1].Split();
    int score = 0;
    // Compare correct answers to student answers
    for (int i = 0; i < answerKey.Length; i++) {
        if (answerKey[i] == studentAnswers[i]) {
            score += 4;
        }
        else if (studentAnswers[i] != "X") {
            score -= 1;
        }
    }
    // Do something with score here.....
}
//close the file
sr.Close();
Console.ReadLine();

Source by coders911.org #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
6+4 =