#!/usr/bin/perl # Tom Blum # May 2007 # IWA-HWG Homework/ Instructor M. Kowalski # Have the user enter two numbers from # standard IO (usually keyboard) print "\n"; print "Enter the first number: "; chomp($number1 = ); print "Enter the second number: "; chomp($number2 = ); # Calculate and print out the results of # some calculations involving those numbers print "\n"; # Addition $sum = $number1 + $number2; print "Addition: \t\t $number1 + $number2 = $sum.\n"; # Subtraction $difference = $number1 - $number2; print "Subtraction: \t\t $number1 - $number2 = $difference.\n"; # Multiplication $product = $number1 * $number2; print "Multiplication: \t $number1 * $number2 = $product.\n"; # check to see if second number is zero before using it as a divisor if($number2 != 0) { # Division $quotient = $number1 / $number2; print "Division: \t\t $number1 / $number2 = $quotient.\n"; # Modulus (remainder) $modulus = $number1 % $number2; print "Modulus: \t\t $number1 % $number2 = $modulus.\n"; } # Exponentiation $exponent = $number1 ** $number2; print "Exponentiation: \t $number1 ^ $number2 = $exponent.\n";