CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012
    Posts
    0

    Post Challenging C++ program challenge. If your up for it

    So i was given an assignment with some unusual parameters. My teacher likes to add difficult objectives to make the code longer (really just to be evil) and this project is proving to be a bit of a problem. I have worked on several programs he has assigned but the one i can not wrap my finger around is the one based on creating answer key and test results for students. I will post it below:

    {



    DECRIPTION
    Write a C++ program to grade multiple-choice, including True/False, questions for an exam given in a class. A class may have one or more sections. The answer keys are the same for all sections of a class for one exam, but the number of students is normally different for different sections. Your program will be used for different classes and/or different exams, and the number of questions will be different. But any exam can have at most 30 questions. The answer key and a student's answer to a question could be a digit, between 1 and 5 (inclusive), or a character among A, B, C, D, E, F and T, or lower case equivalent.

    Input Data
    1. The first value in the input file is the number of questions of the exam.

    2. The second line is the answer keys without spaces between any two answers.

    3. The next line is the number of sections, followed by data for all sections.

    4. The data for a section begins with the number of students, followed by students' data.

    5. The data for each student is on a separate line, beginning with the answers from the student followed by the student's last name.

    6. As the key answers, there is no space between any two answers.

    7. The student's last name comes after his/her last answer without any spaces between.

    8. Any student's last name has at most 15 characters.


    Sample input is given later.
    You can assume the input data are correct and do not check for invalid values.


    Output Data
    1. For each student, last name, number of correct answers, and Pass or Fail. A student passes an exam if the number of correct answers is 60% or better of total number of questions, and fails otherwise.

    For each section, the total number of students and the number of students who passed the exam.

    For the entire class, the number of sections, the total number of students and the number of students who passed the exam.


    See sample output later for the exact output format.

    The following requirements must be followed:

    You must NOT use structs or 2D array.

    You must use the following functions in your program.
    // The function reads in numQuestions answers into array answers.
    // Parameters: (out, in)
    void ReadAnswers(char answers[], int numQuestions);

    // The function compares a student's answers against the answer
    // keys and passes back the number of correct answers and
    // whether the student passed the exam.
    // Parameters: (in, in, in, out, out)
    void ProcessAnswer(const char keys[], const char answers[], int numQuestion, int& correct, bool& pass);

    You must use the same function ReadAnswers() to read the answer keys and the answers for each student.

    You must use for loops to process all sections of the class, all students of a section, and all answers of a student. No while loops are allowed on this assignment.


    Your main() function could be like the following:
    Read number of questions
    Read and store the answer keys
    Read number of sections
    For each section
    Process all students' answers
    Update class results
    Display results for the section
    Display results for the entire class


    You can also use function toupper(x) to convert a character to upper case. You need to include header file <ctype.h> to use the function.

    Sample Input
    10
    t2ft5Ttfft
    2
    4
    T2Ft4ttftTHockney
    t1fF5ffttfHill
    f3ft5fTTftLongwood
    t4Tf5TFTFTSharp
    5
    T2Ft5ttffTHockney
    t2ft4ttfFtHill
    f2ft4tTTftLongwood
    t2Tf5FFTFTSharp
    t2fT5FFTtTQuick

    Sample Output
    Code:
    Name          Correct Answers        PASS/FAIL
    ---------------      ---------------               ---------
          Hockney           8                         PASS
          Hill                    3                         FAIL
          Longwood        6                         PASS
          Sharp               5                         FAIL
    
    2 out of 4 students of section 1 passed the exam.
    
            Name          Correct Answers        PASS/FAIL
    ---------------          ---------------            ---------
            Hockney                   10                PASS
               Hill                          9                PASS
           Longwood                  7                PASS
              Sharp                      5                FAIL
              Quick                      6                PASS
    
    4 out of 5 students of section 2 passed the exam.
    There are 2 sections, and 6 out of 9 students passed the exam.

    }




    So that is the entire thing. I understand if you do not want to help me with all of it however any help will be appreciated. Thank you for anything you are willing to/can do.
    Please feel free to send me questions or emails if you have any questions about it.
    Again you all rock for the help, this community is a great one indeed

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Challenging C++ program challenge. If your up for it

    Quote Originally Posted by flanman1991 View Post
    So i was given an assignment with some unusual parameters. My teacher likes to add difficult objectives to make the code longer (really just to be evil)
    Length of code does not determine difficulty of code. All of the objectives in that assignment should not be difficult, you just need to sit down and complete each one. Also, programming teachers are going to give assignments that few will complete -- the reason being that very few of your fellow students will have the aptitude to write, test, and debug real programs anyway (might as well be blunt about it). Those students will complete this assignment with minimal, if any help needed.

    The way you handle such an assignment is to work on each piece of the assignment. The "write everything at once and hope it works" is not the way to handle this. For example, where is your test function to see if you can read the input correctly? Did you write it? It doesn't matter what the rest of the assignment states, can you read the test input successfully?

    Once you write that routine (and test it), then you start to handle the other parts of the assignment one at a time, testing each piece thorougly before going to the next item.

    When you have specific questions to the assignment, then ask them. It doesn't help posting an entire assignment in a forum expecting "help" without stating what you need help with.

    Regards,

    Paul McKenzie

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured