# won't display answer to math problem

• Beginner
• Posts: 51

3+ Months Ago

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
Code: [ Select ]
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" };
1. print "you can cube or square or multiply numbers
2. with this program first put in a number to work with: ";
3. \$numb = <stdin>;
4. print "now what do you want to do cube , square or multiply?: ";
5. \$Q = <stdin>;
6. if (\$Q eq cube) { \$numb1 = \$numb * \$numb * \$numb };
7. print "\$numb1 is the answer ";
8. if (\$Q eq square) { \$numb2 = \$numb * numb };
9. print \$numb2;
10. if (\$Q eq multiply) { print "put in another number: ";
11. \$numb3 = <stdin>;
12. \$numb4 = \$numb * \$numb3;
13. print "\$numb4 is the answer" };
also if you can help me with the square root thing i'll appreciate it. thanks

## Post Information

• Total Posts in this topic: 1 post
• Users browsing this forum: No registered users and 43 guests
• You cannot post new topics in this forum
• You cannot reply to topics in this forum
• You cannot edit your posts in this forum
• You cannot delete your posts in this forum
• You cannot post attachments in this forum