%[
#!/usr/interp/perl -w

# NESTED IF IN PERL EXAMPLE
# By Louis Ziantz

# Description: This program is a demonstration a nested
#              if structure in Perl.
# Procedure:   A grade is read, and an appropriate
#             grade counter is incremented based on
#             the grade.
# Input:       A letter grade.
# Output:      None.

$a_count = 0;
$b_count = 0;
$c_count = 0;
$d_count = 0;
$f_count = 0;

$grade = <STDIN>;
chomp($grade);
if (($grade eq 'a') || ($grade eq 'A')) {
    $a_count++;
} elsif (($grade eq 'b') || ($grade eq 'B')) {
    $b_count++;
} elsif (($grade eq 'c') || ($grade eq 'C')) {
    $c_count++;
} elsif (($grade eq 'd') || ($grade eq 'F')) {
    $d_count++;
} elsif (($grade eq 'f') || ($grade eq 'F')) {
    $f_count++;
} else {
    print("Invalid grade $grade entered\n.");
}

$grade = <STDIN>;
chomp($grade);
if ("\U$grade" eq 'A') {
    $a_count++;
} elsif (($grade eq 'b') || ($grade eq 'B')) {
    $b_count++;
} elsif (($grade eq 'c') || ($grade eq 'C')) {
    $c_count++;
} elsif (($grade eq 'd') || ($grade eq 'F')) {
    $d_count++;
} elsif (($grade eq 'f') || ($grade eq 'F')) {
    $f_count++;
} else {
    print("Invalid grade $grade entered\n.");
}
%]
