im writing a math program for my sister that will cub, square,multiply and if perl can, square root a number. i wrote the code and it runs but won't display an answer. i wrote print answer but that doesn't work.
my code is this
print "you can cube or square or multiply numbers
with this program first put in a number to work with: ";
$numb = <stdin>;
print "now what do you want to do cube , square or multiply?: ";
$Q = <stdin>;
if ($Q eq cube) { $numb1 = $numb * $numb * $numb };
print "$numb1 is the answer ";
if ($Q eq square) { $numb2 = $numb * numb };
print $numb2;
if ($Q eq multiply) { print "put in another number: ";
$numb3 = <stdin>;
$numb4 = $numb * $numb3;
print "$numb4 is the answer" };
- print "you can cube or square or multiply numbers
- with this program first put in a number to work with: ";
- $numb = <stdin>;
- print "now what do you want to do cube , square or multiply?: ";
- $Q = <stdin>;
- if ($Q eq cube) { $numb1 = $numb * $numb * $numb };
- print "$numb1 is the answer ";
- if ($Q eq square) { $numb2 = $numb * numb };
- print $numb2;
- if ($Q eq multiply) { print "put in another number: ";
- $numb3 = <stdin>;
- $numb4 = $numb * $numb3;
- print "$numb4 is the answer" };
also if you can help me with the square root thing i'll appreciate it. thanks