Help with scantron project please.

This is a discussion on Help with scantron project please. within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by 4 yr old unregistered person Hi. I have a project due Wednesday and I just looked at ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    2
    Quote Originally Posted by 4 yr old unregistered person
    Hi. I have a project due Wednesday and I just looked at it. I don't know where to start. Could some body give me some pointers?

    scantron.cpp

    1. Accepts a scantron quiz key for a 10 item quiz. The first 9 digits are the ID and the next 10 characters are the answers. The key will have an ID of 000000000.

    2. Accepts up to 50 scantron quizzes.

    3. Stops when it encounters a form with an ID of 000000000. Note: The scantron generates the @ character when the answer is blank.

    4. Prints a count of how many forms were scanned.

    5. Prints a list of IDs and scores, as shown below.

    6. Prints an analysis of the answers for each of the 10 questions, as shown below.

    ---Sample Dialogue-----------------------------------------------------

    Key? 000000000ABCDEABCDE
    Quiz? 111111111ABCABCABCA
    Quiz? 234567891ABCDEABCDE
    Quiz? 333333333AAAAAAAAAA
    Quiz? 000000000@@@@@@@@@@

    There were 3 quizzes scanned.

    ID SCORE
    -- --------
    111111111 3
    234567891 10
    333333333 2

    ITEM A B C D E Key
    ----- --- --- --- -- --- ------
    1 3 0 0 0 0 A
    2 1 2 0 0 0 B
    3 1 0 2 0 0 C
    4 2 0 0 1 0 D
    5 1 1 0 0 1 E
    6 2 0 1 0 0 A
    7 2 1 0 0 0 B
    8 1 1 1 0 0 C
    9 1 0 1 1 0 D
    10 2 0 0 0 1 E

    -------------------------------------------------------------------------

    Any help is greatly appreciated!
    I am having trouble with this program myself. I have maybe completed 60% of the program so far:

    Code:
    #include <iostream>
    using namespace std;
    
    
    void main()
    {
    
    	int kID, qID=1, pos=0, qcount=0, correct=0;
    	char key[19];
    	char quiz[50][19]={0};
    
    	cout << "Key? ";
    	for (pos=0; pos<20; pos++)
    	{
    		cin >> key[pos];
    	}
    	
    	while (qID != 0)
    	{
    	qcount++;
    	cout << "Quiz? ";
    
    	cin >> qID;
    	
    	for (pos=0; pos<10; pos++)
    	{	
    		cin >> quiz[qcount][pos];
    	}
    	}
    
    	cout << endl;
    	cout << "There were " << qcount-1 << " quizzes scanned." << endl;
    	cout << endl;
    
    	cout << "ID              SCORE" << endl;
    	cout << "--              -----" << endl;
    	for (pos=0; pos<10; pos++)
    	{
    		cout << quiz[pos]; "              ";
    		//grade quizzes	
    		for (pos=0; pos<10; pos++) 
    		{ 
    			if (quiz[pos] == key[pos])
    			{
    				correct++;
    			}
    		}
    	}
    	//start listing quiz IDs and scores
    	
    		cout << qID << "                 " << "tst" << endl;
    	
    	for (pos=0; pos<10; pos++)
    	{
    		cout << quiz[pos] << endl;
    	}
    
    	cout << "KEY" << endl;
    	for (pos=0; pos<10; pos++)
    		cout << key[pos] << endl;
    	cin.get();cin.get();
    
    
    }
    can anyone help me with direction in this program? I know i need to have a 1d/2d char array, but i'm getting hung up on printing the ID and results for each A, B, C D value
    Last edited by IT-s; 02-06-2006 at 08:41 PM.

  2. #2
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    You've got to be kidding me. It's four years old!
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  3. #3
    Registered User Kurisu's Avatar
    Join Date
    Feb 2006
    Posts
    62
    i guess it took him 4 years to register & apparently he has failed this class atleast 4 times.

    Is this post for real? If so, I'd be willing to help. Maybe he just searched the forums and found this post or perhaps this is a joke? I dunno.. The first post said the work was due Wednesday & today is Monday.. perhaps he is a psychic and knew he would have this assignment 4 years in advance and wanted to get a headstart, but is mentally challenged in some way..


    P.S. I'm not in the Twilight Zone am I? I'm assuming I'm awake.. everything seems normal.. I still have 2 eyes, 10 toes, and 11 fingers..
    Last edited by Kurisu; 02-06-2006 at 12:42 AM.

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    can anyone help me with direction in this program? I know i need to have a char array, but i'm not sure how to initialize and pass variables. in the format stated above.
    "Initializing" a variable means you set it equal to a value when you declare it, e.g.:
    Code:
    int n = 0;
    
    or
    
    char quiz[9][10] = {0}; //sets all the elements equal to '\0'
    You "pass" variables to functons, which doesn't seem be relevant to your program since you don't have any functions.

    There is a problem in your code here:
    Code:
    cout << "Quiz? ";
    cin >> qID;
    
    for (pos=0; pos<10; pos++)
    {	
    	cin >> quiz[i][i];
    }
    First, quiz[][] won't be able to store 50 quizzes(do you only need 9?). Second, where did you declare the variable i? In addition, both index values for quiz[][] shouldn't be i. The first one should be the quiz count. The second one should run from 0-9, so that you can read in 10 characters representing the quiz answers for that quiz.
    Last edited by 7stud; 02-06-2006 at 03:08 AM.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,447
    Split from 4 year old thread Help with scantron project please.
    Try to read the forum rules next time IT-s

  6. #6
    Registered User
    Join Date
    Feb 2006
    Posts
    2
    no, it wasn't a joke, i really have this problem, no, i havn't failed the course. Sorry for bringing back an old post.

    i have updated my first post accordingly

    kurisu, 11 fingers
    Last edited by IT-s; 02-06-2006 at 08:40 PM.

  7. #7
    Registered User Kurisu's Avatar
    Join Date
    Feb 2006
    Posts
    62
    eek, I wish I could help you, but the way you are storing you information is off so helping you patch things together is kinda tough without re-writing it.

    1) You should check the qID right after it is inputed for validity. I could enter zero as the ID, which should be invalid, but your program will accept it the first time.

    2) You are never storing the quiz ID for later retrieval, which should go into quiz[50][0] through quiz[50][9] the way you have set things up while quiz[50][10] through quiz[50][19] should contain the answers.

    3) quiz[pos] == key[pos] wouldn't theoretically work (quiz[quiz#][pos] == key[pos]) because you are comparing test answers to the answer key's ID.. i.e. ABCDEF == 0000000?

    4) You really shouldn't use the same variable name in embedded loops pos in your case.

    5) cout << qID won't work because qID will always be 0 in your code.

    6) cout << quiz[pos] this won't work either I'm afraid as your array is 2D, but you are trying to access it like it is 1D.

    7)
    Code:
    for (pos=0; pos<10; pos++)
    		cout << key[pos] << endl;
    This code will not output the answer key's answers, but merely its ID which will probably be 000000000.

    Uh.. good luck? I consider myself a good programmer, but couldn't patchwork your code the way it is.. sorry to say I think your structures need a re-work.
    If not, perhaps someone else can help you patch 'er up.

    P.S. becareful. Homer Simpson is bald because he went crazy and pulled out all his hair. Hopefully, you haven't reached that point yet.
    Last edited by Kurisu; 02-06-2006 at 10:54 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Displaying a Struct
    By rockstarpirate in forum C++ Programming
    Replies: 16
    Last Post: 05-05-2008, 09:05 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  3. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 07:41 PM
  4. Help with scantron project please.
    By Unregistered in forum C++ Programming
    Replies: 10
    Last Post: 02-18-2002, 09:50 PM

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