| 
 CMSC 201 
Programming Project Five 
Automatic Quiz
 
Out: Sunday 11/25/01 
Due: Before Midnight, Sunday 12/9/01
 
The design document for this project, design5.txt
 is due: Before Midnight, Sunday 12/2/01
 
 | 
The Objective 
The objective of this assignment is to give you experience working with
linked lists.  You'll be using command-line arguments, doing file handling, 
dynamic memory allocation, passing by reference, and comparing strings.  You
will also continue to practice using good program design and implementation 
techniques.
The Background 
The Automatic Quiz is a program students can run that will present them with
questions about material they have covered recently in class.  The questions
are presented to the student one at a time and the program waits for the
student's response.  If the answer is right, the student is informed that s/he
is correct.  If the response is incorrect, the automatic quiz program shows 
the student the correct answer.  The program then proceeds to display the next 
question.
The program keeps track of the questions that the student
has missed.  After the student has finished the quiz, s/he is shown the score, 
and must repeat the questions that had incorrect responses.  After finishing 
the missed questions, a new (hopefully improved) score is calculated and any 
questions that were missed again are shown to the student along with their
correct answers.
The Task 
Design and code a project that uses command-line arguments to get the name of 
the data file from the user to be used for the quiz and uses linked lists to 
store the lists of questions.
Sample Run 
linux1[71] % a.out colors.dat
(Your greeting goes here)
Here are your questions.  Good luck !!!
  1. The primary colors are red, yellow and _________.
blue
Correct
  2. Combining red and yellow pigments produces ______________.
orange
Correct
  3. Combining yellow and blue pigments produces ______________.
green
Correct
  4. Combining blue and red pigments produces ______________.
pink
Sorry, the correct answer is purple
  5. The secondary colors are orange, green and ____________.
blue
Sorry, the correct answer is purple
  6. The complimentary color of red is ______________.
green
Correct
  7. The complimentary color of orange is _____________.
blue
Correct
  8. The complimentary color of purple is _____________.
pink
Sorry, the correct answer is yellow
  9. Combining pigments of any two complimentary colors produces ___________.
black
Sorry, the correct answer is brown
Your score is   55.56%
Improve your score by repeating the ones you missed
Here are your questions.  Good luck !!!
  1. Combining blue and red pigments produces ______________.
purple
Correct
  2. The secondary colors are orange, green and ____________.
yellow
Sorry, the correct answer is purple
  3. The complimentary color of purple is _____________.
yellow
Correct
  4. Combining pigments of any two complimentary colors produces ___________.
brown
Correct
Your new score is   88.89%
These are the questions and answers you need to study:
The secondary colors are orange, green and ____________.
purple
linux1[72] a.out arith.dat
(Your greeting goes here)
Here are your questions.  Good luck !!!
  1. 16 + 5 =
21
Correct
  2. 22 + 6 =
28
Correct
  3. 49 + 4 =
53
Correct
  4. 67 + 8 =
75
Correct
  5. 83 + 7 =
90
Correct
  6. 72 + 21 =
93
Correct
  7. 59 + 33 =
92
Correct
  8. 74 + 21 =
95
Correct
  9. 48 + 35 =
83
Correct
 10. 65 + 13 =
78
Correct
 11. 88 + 16 =
94
Sorry, the correct answer is 104
 12. 95 + 27 =
112
Sorry, the correct answer is 122
 13. 83 + 49 =
132
Correct
 14. 76 + 41 =
117
Correct
 15. 63 + 58 =
121
Correct
 16. 65 - 9 =
54
Sorry, the correct answer is 56
 17. 87 - 5 =
82
Correct
 18. 73 - 8 =
65
Correct
 19. 82 - 6 =
76
Correct
 20. 43 - 7 =
34
Sorry, the correct answer is 36
 21. 66 - 25 =
41
Correct
 22. 85 - 12 =
73
Correct
 23. 92 - 28 =
64
Correct
 24. 87 - 36 =
51
Correct
 25. 53 - 25 =
28
Correct
Your score is   84.00%
Improve your score by repeating the ones you missed
Here are your questions.  Good luck !!!
  1. 88 + 16 =
104
Correct
  2. 95 + 27 =
132
Sorry, the correct answer is 122
  3. 65 - 9 =
56  
Correct
  4. 43 - 7 =
36
Correct
Your new score is   96.00%
These are the questions and answers you need to study:
95 + 27 =
122
linux1[74] % more colors.dat
The primary colors are red, yellow and _________.
blue
Combining red and yellow pigments produces ______________.
orange
Combining yellow and blue pigments produces ______________.
green
Combining blue and red pigments produces ______________.
purple
The secondary colors are orange, green and ____________.
purple
The complimentary color of red is ______________.
green
The complimentary color of orange is _____________.
blue
The complimentary color of purple is _____________.
yellow
Combining pigments of any two complimentary colors produces ___________.
brown
linux1[75] % more arith.dat
16 + 5 =
21
22 + 6 =
28
49 + 4 =
53
67 + 8 =
75
83 + 7 =
90
72 + 21 =
93
59 + 33 =
92
74 + 21 =
95
48 + 35 =
83
65 + 13 =
78
88 + 16 =
104
95 + 27 =
122
83 + 49 =
132
76 + 41 =
117
63 + 58 =
121
65 - 9 =
56
87 - 5 =
82
73 - 8 =
65
82 - 6 =
76
43 - 7 =
36
66 - 25 =
41
85 - 12 =
73
92 - 28 =
64
87 - 36 =
51
53 - 25 =
28
Although your output need not be identical to the above,
all information (including the greeting) must be present.
Input Guarantees
   - All questions will contain 80 characters or less.
   
 - All answers are one-word answers and they will contain 30 characters or 
       less.
   
 - Any data file we use will have the same format as the ones provided,
       colors.dat and arith.dat
 
Further Specifications
   - You must use separate compilation for this project.  You may have as
       many .c and .h files as you want to fit your project design.  Your file
       that contains main() should be called proj5.c  You must have at least 3
       files.
   
 - You must use linked-lists for this project and you must use three of 
       them.  One will be the original list of questions (and correct answers),
       the second will be the list of once-missed questions (and correct 
       answers), and the third will be the list of never-answered-correctly
       questions (and correct answers).  You may NOT have arrays of questions.
   
 - You may use the linked list implementation given in lecture 22.  Some
       of the functions will need minor modification, but some will work as
       they are (if you choose your data structures carefully when designing).
   
 - You MUST use dynamic memory allocation (malloc) to allocate the
       memory for the nodes of the linked lists.  Of course, you must check to
       see that the space was actually given to you.  You must also destroy 
       each list after you are finished using it.
   
 - Even though you must keep track of how many questions there were 
       originally and how many were incorrect each time in order to produce
       a score for the user, you MAY NOT traverse your lists using these
       numbers and counting nodes.  Always traverse lists to their end by 
       examining the next pointer.
   
 - You must write your own DestroyList() function, which will free all of
       the nodes of a linked list that is passed to it.
   
 - You may get copies of the data files from my account as in previous 
       projects.  The files are called colors.dat and arith.dat and they are
       in the /afs/umbc.edu/users/s/b/sbogar1/pub directory.
   
 - The filename of the data file must be given on the command line 
   
 - If the program is run with the wrong number of command line arguments,
       an appropriate message must be printed to the screen informing the user
       how to correctly run the program and then then program must exit.
   
 - If a file fails to open, you should print an appropriate message to
       the screen and exit the program.
   
 - You must close the data file as soon as you are finished reading
       from it.
 
Submitting the Program 
Here is a sample submission command.  Since you may have different file names
you'll have to adjust it to fit your needs.  As always, be sure to submit all
of the files necessary for your project to compile.
Note that the project name starts with uppercase 'P'.
submit cs201 Proj5 proj5.c list.c list.h quiz.c quiz.h
To verify that your project was submitted, you can execute the
following command at the Unix prompt.  It will show the file that
you submitted in a format similar to the Unix 'ls' command.
submitls cs201 Proj5