Help Needed Fast! Multiple Choice Grading Program

This is a discussion on Help Needed Fast! Multiple Choice Grading Program within the C++ Programming forums, part of the General Programming Boards category; Hey there, I'm working on a program that grades multiple-choice exams. It compiles, but I keep getting a linking error, ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    1

    Exclamation Help Needed Fast! Multiple Choice Grading Program

    Hey there,

    I'm working on a program that grades multiple-choice exams. It compiles, but I keep getting a linking error, LNK2019: unresolved external symbol. I can't find this unresolved symbol, and I was wondering if someone else could. Or give some tips on how to fix it? And also, it's due in two hours, so quick help is appreciated!

    Code:

    Code:
    #include <iostream>
    #include <string>
    #include <fstream>
    
    using namespace std;
    
    void OpenFiles (ifstream& inFile, ofstream& outFile);		
    void WrongSize (ofstream& outFile, int keylength, string answers, string key);		
    int main()
    {
    	
    	ifstream inFile;
    	ofstream outFile;
    	OpenFiles(inFile, outFile);
    
    	if (!inFile || !outFile)
    	{
    		cout << "Error opening files." << endl;
    		return 1;
    	}
    
    	string key;
    	string student;
    	string answers;
    	int keylength;
    
    	inFile >> key;
    	keylength = key.length();
    
    	while(inFile >> student >> answers)
    	{
    		outFile << student << " ";
    		WrongSize(outFile, keylength, answers, key);
    	}
    
    return 0;
    }
    
    //**************************************************************
    
    void OpenFiles(ifstream& inFile, ofstream& outFile)
    {
    	string inFileName;
    	string outFileName;
    	cout << "Enter the name of the input file." << endl;
    	cin >> inFileName;
    	inFile.open(inFileName.c_str());
    
    	cout << "Enter the name of the output file." << endl;
    	cin >> outFileName;
    	outFile.open(outFileName.c_str());
    	outFile << "Scores for multiple-choice exam from " << inFileName << endl;
    	outFile << fixed;
    }
    
    void WrongSize(ofstream& outFile, int keylength, string answers, string key)
    {
    	int grade = 0;
    	bool check;
    
    	if (answers.length() < keylength)
    	{
    		outFile << "Too few answers";
    	}
    	else if (answers.length() > keylength )
    	{
    		outFile << "Too many answers";
    	}
    	else
    	{
    		check = false;
    	}
    
    	for (int count = 0; count < key.length(); count++)
    	{
    	if( answers[count] == key[count] )
    	{
    		grade++;
    	}
    	else if (answers[count] != 'a' && answers[count] != 'b' && answers[count] != 'c' && answers[count] != 'd' && answers[count] != 'e' && answers[count] != 'f')
    	{
    		check = true;
    	}
    
    	if (check == true)
    	{
    		outFile << "Invalid Answer";
    	}
    	else
    	{
    		outFile << grade;
    	}
    }
    outFile << endl;
    }
    Last edited by namyad; 11-16-2010 at 01:55 PM.

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,422
    it compiles ok for me apart from warnings about comparison of signed and unsigned ints, can you post a sample file to run it with?
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    Does it matter?
    They wanted it "in 2 hours", and that deadline has long gone.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help needed (problem with basic C program)
    By EpicYuzer in forum C Programming
    Replies: 15
    Last Post: 11-11-2010, 04:38 PM
  2. Replies: 2
    Last Post: 09-16-2009, 06:00 AM
  3. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  4. Help needed with program - urgent thanks!
    By lildevil in forum C Programming
    Replies: 1
    Last Post: 03-09-2008, 06:45 AM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21