#!/usr/bin/perl -wn use strict; # @title = qw(A B C D); my ($sum, $full, @g, $i); my (@class_full) = qw(30 30 30 30 30 30 30); chomp; my ($id, $name, $g1, $warn, $g2, $bonus, $final) = split /:/; unless (defined $final and $id =~ /^\w+\s*$/ and (@g = split " ", "$g1 $g2") and $#g == $#class_full) { print "$_\n"; next; } # 計算平時成績 $sum = $full = 0.0; for ($i=0; $i<=$#g; ++$i) { next if not $g[$i] =~ /^\d+$/; $sum += $g[$i]; $full += $class_full[$i]; } $sum *= 80.0 / $full; ### 期中預警 # $warn = ($sum >= 44) ? "OK" : # ($sum >= 30) ? "C" : # ($sum >= 27) ? "D" : "E"; ### my ($b, $total); $b = ($bonus =~ /^\s*(\d+)\s*$/) ? $1 : 0; $total = $sum + $b + $final/30.0*20; $total = int(sqrt($total)*10); if ($total >= 56) { $total += 3; $total = 60 if $total < 60; } printf "$id:$name:$g1:$warn:$g2:$bonus:$final: %2d\n", $total;