R
rmr531
I have an assignment for a class that has been driving me crazy for the
past few days. Basically I need to create a simple GPA calculator that
takes in several letter grades (ex: A) and then calculates the GPA
based off that A=4 B=3 C=2 D=1 F=0. Here is what I have, sorry it in
inefficient sloppy code but I am still new to this and just want it to
work.
print "Enter the letter grade (A, B, C, D, F) for each test taken in a
class, enter Z to quit.\n";
****************************************
$score=0;
$A="A"; $B="B"; $C="C"; $D="D"; $Z="Z";
for($classes=0, $grade != $Z, $classes++)
{
$grade;
print "Enter a grade: ";
chomp($grade = <STDIN> );
if($grade == $A)
{$score + 4;}
if($grade == $B)
{$score + 3;}
if($grade == $C)
{$score + 2;}
if($grade == $D)
{$score + 1;}
else {$score + 0;}
}
$gpa=$score/$classes;
print "Your GPA is: $gpa.\n";
*******************************************************
Any help on this one is greatly appreciated, I know many of you out
there are PERL experts but if you could make the solutions very basic
that would be great, remember this is a beginner class
I know it is
something stupid that I did but I cannot figure it out, I think that my
logic is sound. Thanks all.
past few days. Basically I need to create a simple GPA calculator that
takes in several letter grades (ex: A) and then calculates the GPA
based off that A=4 B=3 C=2 D=1 F=0. Here is what I have, sorry it in
inefficient sloppy code but I am still new to this and just want it to
work.
print "Enter the letter grade (A, B, C, D, F) for each test taken in a
class, enter Z to quit.\n";
****************************************
$score=0;
$A="A"; $B="B"; $C="C"; $D="D"; $Z="Z";
for($classes=0, $grade != $Z, $classes++)
{
$grade;
print "Enter a grade: ";
chomp($grade = <STDIN> );
if($grade == $A)
{$score + 4;}
if($grade == $B)
{$score + 3;}
if($grade == $C)
{$score + 2;}
if($grade == $D)
{$score + 1;}
else {$score + 0;}
}
$gpa=$score/$classes;
print "Your GPA is: $gpa.\n";
*******************************************************
Any help on this one is greatly appreciated, I know many of you out
there are PERL experts but if you could make the solutions very basic
that would be great, remember this is a beginner class
something stupid that I did but I cannot figure it out, I think that my
logic is sound. Thanks all.