# !perl/bin/perl -w #Lab 7a #XXXX XXXX #My full name...Yeah. #Calculates grade averages open (INPUT, "Tscore.dat") || die "Cannot open input file.\n"; open (OUTPUT, ">L7AOUT.txt") || die "Cannot open file.\n"; print OUTPUT " CLASS TEST AVERAGES\n\n"; print OUTPUT " TEST\n"; print OUTPUT "NAME OF STUDENT AVERAGE\n\n"; read (INPUT, $studentname, 20); read (INPUT, $test1, 3); read (INPUT, $test2, 3); read (INPUT, $test3, 3); read (INPUT, $test4, 3); read (INPUT, $eor, 1); <INPUT>; $studentname3 = uc(substr ($studentname, 0, 3)); while ($studentname3 ne "END") { $avg = ($test1 + $test2 + $test3 + $test4) / 4; $studnum = $studnum + 1; $totavg = $totavg + $avg; printf OUTPUT ("%-24.20s %6.2f", $studentname, $avg); print OUTPUT "\n\n"; read (INPUT, $studentname, 20); read (INPUT, $test1, 3); read (INPUT, $test2, 3); read (INPUT, $test3, 3); read (INPUT, $test4, 3); read (INPUT, $eor, 1); <INPUT>; $studentname3 = uc(substr ($studentname, 0, 3)); } $totavg = $totavg / $studnum; print "\n\n"; printf OUTPUT ("%-24.22s %6.2f", $studnum, $totavg); print "Program completed Successfully."; close INPUT; close OUTPUT; exit 0;
In reply to Re: I'm having a strange bug with basic file input. I'm a total newb.
by KingCupons
in thread I'm having a strange bug with basic file input. I'm a total newb.
by KingCupons
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |