sum percentages as sanity check

This commit is contained in:
Eric House 2013-11-22 18:51:17 -08:00
parent 14fa77cf2d
commit 85a49885fb

View file

@ -47,14 +47,19 @@ print "Number of letters: $letterCount\n\n";
print "**** word sizes ****\n";
print "SIZE COUNT PERCENT\n";
my $pctTotal = 0.0;
my $wordTotal = 0;
for ( my $i = 1 ; $i <= 99; ++$i ) {
my $count = $wordSizeCounts[$i];
$wordTotal += $count;
if ( $count > 0 ) {
my $pct = (100.00 * $count)/$wordCount;
printf "%2d %5d %.2f\n", $i, $count, $pct;
$pctTotal += $pct;
printf "%2d %6d %.2f\n", $i, $count, $pct;
}
}
printf "-------------------------------\n";
printf " %6d %.2f\n", $wordTotal, $pctTotal;
print "\n\n**** Letter counts ****\n";