#!/usr/bin/perl
# Fig. 3.10: fig03_10.pl
# Average-sales problem with counter-controlled repetition

# initialization phase
$total = 0;                       # clear total
$weekCounter = 1;                 # prepare to loop

# processing phase
while ( $weekCounter <= 10 ) {    # loop 10 times

   # prompt for input and input a sales value
   print "Enter sales for week $weekCounter: ";
   chomp( $sales = <STDIN> );

   $total += $sales;              # add sales to total
   ++$weekCounter;                # increment counter
}

$average = $total / 10;           # divide to find average
print "\nSales averaged $average computers per week\n";
