Java Reference
In-Depth Information
LISTING 8.14
continued
for ( int soda=0; soda < SODAS; soda++)
System.out.println ("Soda #" + (soda+1) + ": " +
fmt.format (( float )sodaSum[soda]/PEOPLE));
System.out.println ();
for ( int person=0; person < PEOPLE; person++)
System.out.println ("Person #" + (person+1) + ": " +
fmt.format (( float )personSum[person]/SODAS));
}
}
OUTPUT
Averages:
Soda #1: 3.2
Soda #2: 2.6
Soda #3: 4.2
Soda #4: 1.9
Person #1: 2.2
Person #2: 3.5
Person #3: 3.2
Person #4: 3.5
Person #5: 2.5
Person #6: 3
Person #7: 2
Person #8: 2.8
Person #9: 3.2
Person #10: 3.8
Suppose a soda manufacturer held a taste test for four new flavors to see how
people liked them. The manufacturer got 10 people to try each new flavor and
give it a score from 1 to 5, where 1 equals poor and 5 equals excellent. The two-
dimensional array called scores in the SodaSurvey program stores the results of
that survey. Each row corresponds to a soda and each column in that row corre-
sponds to the person who tasted it. More generally, each row holds the responses
that all testers gave for one particular soda flavor, and each column holds the
responses of one person for all sodas.
Search WWH ::




Custom Search