#!/usr/bin/perl use strict; use warnings; #785290 my $Google=30; my $Yahoo=23; my $Bing=12; my $sum=$Google + $Yahoo + $Bing; my $google_percent = $Google/$sum; print "G: $google_percent"; my $yahoo_percent = $Yahoo/$sum; print "\tY: $yahoo_percent"; my $bing_percent = $Bing/$sum; print "\tB: $bing_percent \n"; my $total = ($google_percent + $yahoo_percent + $bing_percent); my $roundedG = sprintf("%.2f", $google_percent); my $roundedY = sprintf("%.2f", $yahoo_percent); my $roundedB = sprintf("%.2f", $bing_percent); my $rounded = sprintf("%.2f", $total); print "Google: $roundedG; Yahoo: $roundedY; Bing: $roundedB; Total: $rounded \n"; printf ('%.0f', (($Google/$sum)*100)); print "%\n"; printf ('%.0f', (($Yahoo/$sum)*100)); print "%\n"; printf ('%.0f', (($Bing/$sum)*100)); print "%\n"; print $rounded*100 . "% (Percentages may not add up to 100 because of rounding errors!)\n";