hi, I am new to perl and am trying to build a grade # #calculator.I have gone through the code for hours and am# #stuck. can some one point me in the right direction? it # #looks to me like it should be running.
########################################################## #located in = /var/www/htdocs/index.html
####################################################################################################################### #<html> <head></head> <form action=/cgi-bin/math4.cgi method=post> <center> <h1>Grade Calculator</h1> task1:<input type=text name=g1 maxlength=3 size=3><br> task2:<input type=text name=g2 maxlength=3 size=3><br> task3:<input type=text name=g3 maxlength=3 size=3><br> task4:<input type=text name=g4 maxlength=3 size=3><br><br> <h1>How to's</h1> <br> 0<input type=radio value=0 name=g5><br> 25<input type=radio value=25 name=g5><br> 50<input type=radio value=50 name=g5><br> 75<input type=radio value=75 name=g5><br> 100<input type=radio value=100 name=g5><br> <h1> Attitude</h1> <select name=g6> <option>0</option> <option>25</option> <option>50</option> <option>75</option> <option>100</option> </select><br><br> <br><input type=reset><br> <input type=submit> </center> </body> </form> </html>
located var\www\cig-bin\math4.cgi|chmod 755 math4.cgi
####################################################################################################################### ##!/usr/bin/perl use CGI ':standard'; $g1=param('g1'); $g2=param('g2'); $g3=param('g3'); $g4=param('g4'); $g5=param('g5'); $g6=param('g6'); $letter; $average; $div; $total=($g1 + $g2 + $g3 + $g4 + $g5 + $g6); sub div{ if($g1 ne ''){$div++;} if($g2 ne ''){$div++;} if($g3 ne ''){$div++;} if($g4 ne ''){$div++;} if($g5 ne ''){$div++;} if($g6 ne ''){$div++;} } $average=($g1 + $g2 + $g3 + $g4 + $g5 + $g6) / $div; sub letter{ if ($average > 100) {print "illegal average, check your grades";} if($average > 92.5){$letter="A"; } elsif($average > 89.5){$letter="A-"; } elsif($average > 87.5){$letter="B+"; } elsif($average > 82.5){$letter="B"; } elsif($average > 79.5){$letter="B-"; } elsif($average > 76.5){$letter="C+"; } elsif($average > 72.5){$letter="C"; } elsif($average > 69.5){$letter="C-"; } elsif($average > 66.5){$letter="D+"; } elsif($average > 62.5){$letter="D"; } elsif($average < 62.4){$letter="F"; } print " <li> the letter grade is $letter <br /> "; }
sorry if this post is to big or asked incorrectly I am #still learning. #I ran the math4.cgi through shell console and no errors #came up except that dividing by zero was an illegal #command.when I run localhost through fire fox the html #works but I get the ocal server error screen and it says it #can't find math4.cgi in the cgi-bin directory. #any help is appreciated.
###########################################################In reply to grade calulator coding problem by friar tux
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |