#! /perl/bin/perl #c04ex6.cgi - calculates the total price of widgets purchased print "Content-type: text/html\n\n"; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); #prevent Perl from creating undeclared variables use strict; #declare variables my ($salesperson, $sales, $k, $commission, $percentage, $newrates); my %rates2 = ("0", .05, "1", .06, "2", .07); my @rates = param('Rate'); #assign values to variables $salesperson = param('Salesperson'); $sales = sprintf "\$%.2f", param('Sales'); #calculate total ordered and total sale #create Web page print < Patton Industries

Bonus Calculation


Sales Person: $salesperson
Sales: $sales
here foreach $k(@rates) { $newrates = ($rates2{$k}) * 100; $commission = ($sales * ($rates2{$k})); printf "Using a rate of %.1f%%, \n", $newrates; print "your bonus is $commission
\n"; } print "\n"; print "\n";