Thread: Help with program.

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    3

    Question Help with program.

    I'm designing a multiple-choice question grading program using functions and 1-dimension arrays. I input: the key to the questions, the number of students taking the exam, the student's answers, followed by the student's names. Then output--the student's name; followed by the number of correct answers; followed by PASS if the number correct is 60% or better or FAIL otherwise.

    Now, I can't figure out how I would make the 'key' check the student's answers..and also bout the names, would I have to use file input/output just to store the different names in a text file? if so, how would I do that exactly?

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    try it, post code, ask a question of exactly what is giving you problems, then we'll be glad to help.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    162
    Making the key check the answers is easy, provided you have inputed the key into RAM from a file or manually in the program. Just use comparisons on the students answers and the key's answers:
    for(USHORT i=0; i<numofquestions; i++)
    {
    if(test[i] == key[i])
    score += 1; //add one to the score to determine the final score
    else
    continue;
    }
    I'm not sure what you mean about the names, but this should get you started

  4. #4
    Geo Geo Geo-Fry
    Join Date
    Feb 2003
    Posts
    116
    and also bout the names, would I have to use file input/output just to store the different names in a text file? if so, how would I do that exactly?
    if you are asking the question i think you are asking, which i think that you are, then no, you wouldnt have to use file input/output, unless you wanted them to be there the next time you ran the program. so, if you added a student named john doe this time, for him to be when you next run the program who will need to do file manipolation. if however you only need them there temporarily, then you dont need file manipulation

    <off topic>
    isnt manipulation a cool word? i think that it is
    </off topic>
    "You can lead a man to Congress, but you can't make him think."
    "The Grand Old Duke of York
    -He had ten thousand men.
    -His case comes up next week."
    "Roses are red, violets are blue, I'm schizophrenic, and so am I."
    "A computer once beat me at chess, but it was no match for me at kick boxing."
    "More and more of our imports are coming from overseas."
    --George W. Bush
    "If it weren't for electricity, we'd all be wacthing TV by candlelight."
    --George W. Bush

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    "would I have to use file input/output just to store the different names in a text file?"

    Yes, you need to do file input/output to store the names in a text file.

    "if so, how would I do that exactly?"
    Code:
    #include <fstream>
    #include <string>
    using namespace std;
    
    int main()
    { 
    	string name;
    	name ="Sally Johnson";
    	
    	ofstream outFile("C:\\TestData\\output.txt");
    	outFile<<name<<endl;	
    	
    	return 0;
    }
    Last edited by 7stud; 05-05-2003 at 08:00 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM