crokett
03-22-2001, 11:55 PM
i am learning perl. this is a script i wrote that uses a while loop, but the while is not working. the program just keeps running and does not exit properly. it does not matter what is entered by the user. any help is appreciated.
thanks
$ANS="y";
while ($ANS=="y" or $ANS=="Y"){
print "Enter the height:";
$HEIGHT=<STDIN>;
$WIDTH=$HEIGHT*2;
$LEDGE=sqrt(($HEIGHT**2)+($HEIGHT**2));
$LSPAR=$HEIGHT*1.09;
$SPREADR=$HEIGHT*.85;
$KLENGTH=$HEIGHT*.79;
$KSSIDE=$HEIGHT*.33;
$KLSIDE=$HEIGHT*.69;
$SPREADRLOC=$HEIGHT*.81;
print "The height of the kite is $HEIGHT feet.\n";
print "The width of the kite is $WIDTH feet.\n";
printf ("The leading edge is %.2f feet long. \n", $LEDGE);
printf ("The leading edge spar is %.2f feet long.\n", $LSPAR);
print "The spreader is $SPREADR feet long.\n";
print "The keel is $KLENGTH feet long.\n";
print "The keel short side is $KSSIDE feet long.\n";
print "The keel long side is $KLSIDE feet long.\n";
print "The spreader is located $SPREADRLOC feet up the leading edge.\n";
print "\n";
print "Size another kite? Enter y or n: ";
$ANS=<STDIN>;
chop($ANS);
}
thanks
$ANS="y";
while ($ANS=="y" or $ANS=="Y"){
print "Enter the height:";
$HEIGHT=<STDIN>;
$WIDTH=$HEIGHT*2;
$LEDGE=sqrt(($HEIGHT**2)+($HEIGHT**2));
$LSPAR=$HEIGHT*1.09;
$SPREADR=$HEIGHT*.85;
$KLENGTH=$HEIGHT*.79;
$KSSIDE=$HEIGHT*.33;
$KLSIDE=$HEIGHT*.69;
$SPREADRLOC=$HEIGHT*.81;
print "The height of the kite is $HEIGHT feet.\n";
print "The width of the kite is $WIDTH feet.\n";
printf ("The leading edge is %.2f feet long. \n", $LEDGE);
printf ("The leading edge spar is %.2f feet long.\n", $LSPAR);
print "The spreader is $SPREADR feet long.\n";
print "The keel is $KLENGTH feet long.\n";
print "The keel short side is $KSSIDE feet long.\n";
print "The keel long side is $KLSIDE feet long.\n";
print "The spreader is located $SPREADRLOC feet up the leading edge.\n";
print "\n";
print "Size another kite? Enter y or n: ";
$ANS=<STDIN>;
chop($ANS);
}