dacka has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl print"###simple calculator program##\n\n"; until ($opt2 eq'y') { print "enter the first number\n"; $num1=<>; print "enter the second number\n"; $num2=<>; print "enter your option\n\+ for addition\n\- for subtraction\n\* for +multiplication\n\/ for divison\n option:"; $opt=<>; chomp($opt); if ($opt eq'+') { print "you pressed the \+key\n press any key to continue\n"; <>; $ans=$num1+$num2; print "the answer is $ans\n"; } elsif ($opt eq'-') { print "you pressed the \-key\n press any key to continue\n"; <>; $ans=$num1-$num2; print "the answer is $ans\n"; } elsif ($opt eq'*') { print "you pressed the \*key\n press any key to continue\n"; <>; $ans=$num1*$num2; print "the answer is $ans\n"; } elsif ($opt eq'/') { print "you pressed the \/key\n press any key to continue\n"; <>; $ans=$num1/$num2; print "the answer is $ans\n"; }else { print "you have entered wrong option\n"; } print " do you want to continue press y or n?\n"; $opt2=<>; }else { print "thanks for using\n"; } <>;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: help me to find out the error??
by marto (Cardinal) on Apr 11, 2014 at 14:06 UTC | |
|
Re: help me to find out the error??
by Laurent_R (Canon) on Apr 11, 2014 at 18:56 UTC | |
|
Re: help me to find out the error??
by LanX (Saint) on Apr 11, 2014 at 13:46 UTC | |
by dacka (Initiate) on Apr 11, 2014 at 13:47 UTC | |
by LanX (Saint) on Apr 11, 2014 at 13:55 UTC | |
by marto (Cardinal) on Apr 11, 2014 at 14:10 UTC | |
by davido (Cardinal) on Apr 11, 2014 at 14:12 UTC |