Welcome to the Monastery PerlMonks

### Voting Booth does't add up

by eak (Monk)
 on Aug 12, 2000 at 08:22 UTC Need Help??

I was in the voting booth today and I noticed that the percentages for the 90 votes only added up to 96%. If we have a voting booth, shouldn't the %'s = 100? I took this as a challenge to write a better voting booth rounder.
--eric
```#!/usr/bin/perl -w
use strict;

plane => 5,
cbn   => 10,
wall  => 2,
pass  => 11,
shirt => 5,
vison => 7,
mind  => 26,
name  => 10,
tooth => 14,
);
my \$total;
\$total += \$_;
}
my %pcts;
my \$diff = 100;

my \$pct = \$votes{\$vote}/\$total * 100;
\$diff -= int(\$pct);
\$pcts{\$vote} = \$pct;
}

my \$format = "%-12s" x 3;
printf("\$format\n", @titles);

my \$new_total = 0;
foreach my \$answ (sort { (\$pcts{\$b} - int(\$pcts{\$b}))
<=>
(\$pcts{\$a} - int(\$pcts{\$a}))
} keys %pcts ){

my \$round = int(\$pcts{\$answ});
\$round += 1 if \$diff-- > 0;
\$pcts{\$answ});
\$new_total += \$round;
}

print "\n\tNew % Total: \$new_total%\n";

Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: monkdiscuss [id://27607]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-01-21 21:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
In 2022, my preferred method to securely store passwords is:

Results (59 votes). Check out past polls.

Notices?