Average-sales problem with counter-controlled repetition
$total = 0; $weekCounter = 1; while ( $weekCounter <= 5 ) { print "Enter sales for week $weekCounter: "; chomp( $sales = <STDIN> ); $total += $sales; ++$weekCounter; } $average = $total / 5; print "\nSales averaged $average computers per week\n";