The local driver's license office has asked you to create an application that grades the written portion of the driver's license exam. The exam has 20 multiple choice answers..Your program should store these correct answers in the array. The program should read the students answers for each of the 20 questions from a text file and store the answers in another array. After the student's answers have been read from the file the program should display a message indicating whether the student passed or failed. 15 out of 20 is passing. Should then display total number of correctly and incorrectly answered questions, and a list showing the question numbers of the incorrectly answered questions...
I am having a hard time figuring out how to actually get the program to grade my text file. I am not sure how to compare them. I have looked all through my book but the only similar example uses only int data types. Any help would be greatly appreciated!
Here is what I have done so far...this time..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace DriverLicenseExamProb
{
public partial class driverExam1 : Form
{
public driverExam1()
{
InitializeComponent();
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void GradeButton_Click(object sender, EventArgs e)
{
const int ANSWER = 20;
int[] tstAns = new int[ANSWER];
int index = 0;
StreamReader inputFile;
inputFile = File.OpenText("answer.txt");
while (index < tstAns.Length && !inputFile.EndOfStream)
{
tstAns[index] = int.Parse(inputFile.ReadLine());
index++;
}
inputFile.Close();
}
{
const int KEY=20;
string[] ansKey=new string[KEY];
string[] ansKEY={"B", "D", "A", "A", "C", "A", "B", "A", "C", "D",
"B", "C", "D", "A", "D", "C", "C", "B", "D", "A"};
}
}
}

New Topic/Question
Reply



MultiQuote





|