#!/usr/bin/perl require("cgi-lib.pl"); print "Content-type: text/html\n\n"; $Message = ' '; $haveweight = (1==2); $haveminutes = (1==2); # Read in all the variables set by the form if (&ReadParse(*input)) { #print "ReadParse returned true."; # this meains someone filled in the form at least once &do_calc(); } else { #print "ReadParse returned false."; # this means first time in, just show the form $Message = 'Please fill in the form below, then use the Calculate button.'; $input{'Activity'} = 'Moderate'; } &show_form(); exit; sub do_calc { if (!defined($input{'Weight'})) { $Message = $Message . "Please enter weight."; $haveweight = (1==2); } else { $weight = $input{'Weight'}; $haveweight = (1==1); if ($weight <=0) { $Message = $Message . "Weight must be greater than 0."; $haveweight = (1==2); } } if (!defined($input{'Minutes'})) { $Message = $Message . " Please enter minutes."; $haveminutes = (1==2); } else { $minutes = $input{'Minutes'}; $haveminutes = (1==1); if ($minutes <=0) { $Message = $Message . " Minutes must be greater than 0."; $haveminutes = (1==2); } } if ($haveminutes && $haveweight) { #Kilocalories burned = 0.036 x duration in min x weight in lbs if (defined($input{'Activity'}) && $input{'Activity'} eq 'Moderate') { $Kilocalories = 0.036 * $minutes * $weight; } else { $Kilocalories = 0.056 * $minutes * $weight; } } } sub show_form { print < Spiderflex Unisex Bicycle Saddle - Calorie Calculator EOF print '
\n"; print "
\n"; print "

Spiderflex Calorie Calculator

\n"; print "$Message" . "
\n"; print "
\n"; #if ($haveminutes && $haveweight) { # print "Calories Burned = " . $Kilocalories . "
\n"; #} #else { # print "
\n"; #} #print "
\n"; print "Weight ( lbs ): "; print '\n"; print "
"; print "Minutes: "; print '\n"; print "
"; #print "Intensity: "; #print " input returned: "; #if (defined($input{'Activity'})) { # print $input{'Activity'}; #} print 'Moderate Pace ( 10 mph ):
' . "\n"; print 'Fast Pace ( 15 mph ):
' . "\n"; print "
\n"; if ($haveminutes && $haveweight) { print "Calories Burned = " . $Kilocalories . "
\n"; } else { print "
\n"; } print "
\n"; print <

NOTE * This calorie calculator is to be used only as an estimated average. Variables such as wind speed, climb grade, gear ratio, etc. will affect the calculation.

EOF }