Search for question
Question

A group of chimpanzees at Gotham Zoo are given a series of tasks to perform every morning

to test their mood and abilities to do work. There are 2 rooms (call them room A and

room B) open to them each containing 4 tasks; the chimps learn that they immediately get

a special treat when they complete any 5 tasks total out of both rooms. So each day they

get to choose which tasks that they wish to complete. For each task that they successfully

attempt a computer records their success in completing the task as a integer score in the

range of 1-50 (inclusive). Unattempted tasks are indicated with a score of 0, and a negative

score indicates a data error that usually indicates the chimp abused the equipment. Any

trials with negative individual scores or no attempts are not counted in the overall statistics.

Also if more tasks than required are completed, then the first ones completed in order are

counted and the later ones are disregarded.

Write a C program to read in each chimp's id number (a 4 digit value) followed by 8 scores

(with each score being in the range 0-50 inclusive). An id number of 0 indicates the end of

input. The data collection computer guarantees that the correct number of input values are

always recorded and that the end-of-data is always indicated with a 0 for the id.

Here is some sample input data:

2199 20 0 0 20 0 20 20 20

7001 0 0 0 0 0 0 0 0

7012 0 20 0 0 0 0 20 20

4000-1 -1 -1 -1 -1 -1 -1 -1

1422 20 0 18 20 0 20 19 20

1372 -1 -1 18 11 0 20 0 20

0

Input to your program must come from standard input via redirection on the command

line (as discussed in class; see the sample run below). You will echo print each student's

id and scores along with printing out their result and all appropriate comments; do this in

the table format shown in the sample run. Output, including all labels and spacings, must

appear exactly as it appears in the sample run below. Depending on the data entered your

program should also print out one of the following comments where appropriate (where n is

the number of valid trials):

Fig: 1