#!/usr/local/bin/perl

#                  Base   Tuit.  Travel
$monthly{'Mar'}  = 3.58        + 0.08 ;
$monthly{'Apr'}  = 7.17        +.0.16 ;
$monthly{'May'}  = 7.17 + 0.60 + 0.16 ;
$monthly{'Jun'}  = 7.17 + 0.30 + 1.20 ;
$monthly{'Jul'}  = 7.17        + 0.16 ;
$monthly{'Aug'}  = 7.17        + 1.00 ;
$monthly{'Sep'}  = 7.17 + 1.90 + 0.80 ;
$monthly{'Oct'}  = 7.17 + 0.90 + 0.16 ;
$monthly{'Nov'}  = 7.17        + 1.90 ;
$monthly{'Dec'}  = 7.17        + 0.16 ;
$monthly{'Jan'}  = 7.17 + 1.90 + 1.50 ;
$monthly{'Feb'}  = 7.17 + 0.90 + 0.16 ;
$monthly{'Mar '} = 3.69        + 0.08 ;

$total = shift @ARGV;

print "Total cost: \$$total\n";
print "Estimated monthly expenditure (in thousands of dollars)\n";

foreach $i ('Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
    'Nov', 'Dec', 'Jan', 'Feb', 'Mar ') {

    printf("   %s", $i);
}

printf "\n";

$check = 0;
$pct = 0;

foreach $i ('Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
    'Nov', 'Dec', 'Jan', 'Feb', 'Mar ') {

    $amt = $total * $monthly{$i} / 100.0 ; 
    $check += $amt;
    $pct   += $monthly{$i}; 
    printf(" %5.1f", $amt/1000);
}

print "\n";

print "\n double check: $pct% \$$check\n";
