go to previous page   go to home page   go to next page        

Answer:

The claimed amount data, 5, does not agree with the actual amount of data.

Groups of Data

The program might be improved with a while statement that uses hasNextInt() to ensure that the loop body can be executed.

However, sometimes a counting loop must be used with input. The data sometimes consist of several groups where each group starts with a header that says how much data is in that group. For example:

There are two groups of computer science students. The first group (called group "A") uses on-line lessons. The other group (called group "B") uses traditional printed text. All the students are given the same mid-term examination. Which group has the higher test average?

The file of test scores looks like this (the blue comments are not in the file):

3         <-- number of students in group "A"
87
98
95
4         <-- number of students in group "B"
78
82
91
84

Group "A" has three students in it and group "B" has four students in it. The program is to compute two averages from the data in this file.

QUESTION 7:

What will be the structure of the program that does this? Click here for a