I started perl a few days ago so are there any ways to make this chunk of code more efficient? The user is supposed to input a score and it'll display something like "The student has gotten a A grade for the score of 100."
Thanks in advance. Victor#!/usr/bin/perl -w if($ARGV[0] ~~ [0..39]){ print "The student has gotten a F grade for the score of $ARGV[0]. +"; }elsif($ARGV[0] <= 49) { print "The student has gotten a E grade for the score of $ARGV[0]. +"; }elsif($ARGV[0] <= 59) { print "The student has gotten a D grade for the score of $ARGV[0]. +"; }elsif($ARGV[0] <= 64) { print "The student has gotten a C grade for the score of $ARGV[0]. +"; }elsif($ARGV[0] <= 69) { print "The student has gotten a C+ grade for the score of $ARGV[0] +."; }elsif($ARGV[0] <= 74) { print "The student has gotten a B grade for the score of $ARGV[0]. +"; }elsif($ARGV[0] <= 79) { print "The student has gotten a B+ grade for the score of $ARGV[0] +."; }elsif($ARGV[0] <= 100) { print "The student has gotten a A grade for the score of $ARGV[0]. +"; }else { print "Please enter a value between 0 and 100"; }
In reply to conditional statement by victorlai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |