518
boolean[] failing = new boolean[NUM_STUDENTS];
boolean[] passing = new boolean[NUM_STUDENTS];
int[] score = new int[NUM_STUDENTS];
}
1.Write a Java instance method that initializes all components of failingto
false.
2.Write a Java instance method that sets the components offailingtotrue
wherever the corresponding value inscoreis less than 60.
3.Write a Java instance method that sets the components of passingto truewher-
ever the corresponding value in scoreis greater than or equal to 60.
4.Write a Java value-returning instance method passTallythat reports how many
components in passingare true.
5.Write a Java value-returning instance method errorthat returns trueif any cor-
responding components in passingand failingare the same.
6.Write a Java value-returning instance method that takes an integer gradeas a
parameter and that reports how many values in scoreare greater than or equal
to grade.
7.Write a Java instance method that reverses the order of the components in
score; that is,score[ 0 ]goes into score[score.length – 1 ],score[ 1 ]goes into
score[score.length – 2 ], and so on.
8.Write a code segment to read in a set of part numbers and associated unit
costs, separated by blanks. Use an array of class objects with two members,
numberand cost, to represent each pair of input values. Assume the end-of-file
condition terminates the input.
Programming Problems
1.The local baseball team is computerizing its records. The team has 20 players,
identified by the numbers 1 through 20. Their batting records are coded in a file.
Each line in the file contains four numbers: the player’s identification number and
the number of hits, walks, and outs he or she made in a particular game. Here is a
sample:
3 2 1 1
This example indicates that during a game, player number 3 was at bat four
times and made two hits, one walk, and one out. For each player, there are sev-
eral lines in the file. To compute each player’s batting average, one adds the
player’s total number of hits and divides by the total number of times at bat. A