< previous page page_645 next page >

Page 645
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Output:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
First line-appropriate headings.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Next n records-transaction number, whether accepted or rejected; weight; and cost.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Last line-number of packages processed, number of packages rejected.
7. The final exam in your psychology class consists of 30 multiple-choice questions. Your instructor says that if you write the program to grade the finals, you won't have to take the exam.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Input:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
The first data line contains the key to the exam. The correct answers are the first 30 characters; they are followed by an integer number that says how many students took the exam (call it n).
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
The next n lines contain student answers in the first 30 character positions, followed by the student's name in the next 10 character positions.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Output:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
For each student-the student's name; followed by the number of correct answers; followed by PASS if the number correct is 60 percent or better, or FAIL otherwise.
Case Study Follow-Up
1. For the Comparison of Two Lists case study, rewrite the program by eliminating the assumption that the two lists are of equal length. If one list is longer than the other, print a message indicating which is longer, and stop the comparison.
2. In the Frequency of Certain Characters case study, the GetCharList function declares a formal parameter charList. Would it be all right to prefix the declaration of charList with the word const? Explain.
3. Modify the CountAll program so that its output is the same as the CharCount program; that is, print the frequency of occurrence of a specified list of characters.

 
< previous page page_645 next page >