@opinions = ( 8, 9, 4, 7, 8, 5, 6, 4, 9, 9,
6, 7, 3, 4, 8, 7, 9, 8, 9, 2 );
$total = 0;
foreach ( @opinions ) {
$total += $_;
}
print $total;
@opinions = ( 8, 9, 4, 7, 8, 5, 6, 4, 9, 9,
6, 7, 3, 4, 8, 7, 9, 8, 9, 2 );
# determine the mean
$total = 0;
foreach ( @opinions ) {
$total += $_;
}
$mean = $total / @opinions;
print "Survey mean result: $mean\n";
|