Skip to content

Instantly share code, notes, and snippets.

@xydinesh
Created November 1, 2011 22:23
Show Gist options
  • Save xydinesh/1332139 to your computer and use it in GitHub Desktop.
Save xydinesh/1332139 to your computer and use it in GitHub Desktop.
HW8-5
#!/usr/bin/perl
my %grades;
while (<>){
chomp;
($lname, $fname, $asm, $score) = split(/,/);
if (exists $grades{$lname}){
$grades{$lname}{$asm} = $score;
}else{
$grades{$lname} = {"firstname" => $fname, $asm => $score};
}
}
foreach (keys %grades){
$t = 0.2*$grades{$_}{"hw"} + 0.3*$grades{$_}{"midterm"} + 0.5*$grades{$_}{"final"};
print $_, ", ", $grades{$_}{"firstname"}, " ", $t, "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment