#!/usr/bin/perl use strict; use warnings; print"###simple calculator program##\n\n"; my $opt2=""; while ($opt2 ne 'y'){ my $ans; print "enter the first number\n"; chomp( my $num1 = <> ); print "enter the second number\n"; chomp( my $num2 = <> ); print "enter your option\n\+ for addition\n\- for subtraction\n\* for multiplication\n\/ for divison\n option:"; chomp(my $opt = <>); if ($opt eq '+'){ print "you pressed the \+key\n"; $ans = $num1 + $num2; print "the answer is $ans\n"; }elsif ($opt eq '-'){ print "you pressed the \-key\n"; $ans = $num1 - $num2; print "the answer is $ans\n"; }elsif ($opt eq '*'){ print "you pressed the \*key\n"; $ans = $num1 * $num2; print "the answer is $ans\n"; }elsif ($opt eq '/'){ print "you pressed the \/key\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"; chomp ($opt2 =<>); } }