The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 02-09-2009
daddygrant daddygrant is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 5
I change the values for comparison from string to integers but I still receive the same error. "Syntax error.. might be a runaway multi-line"

Code:
print 'Welcome to the Calculator';
print 'Would you like to enter the calculator? Please Type y or n';
$run = <stdin>;
chomp $run;
while ($run == y)
    {
        {    
        print 'Add = 1 | Subtract = 2 | Multiply = 3 | Divide = 4 |Exponent = 5 | Mod = 6 ';
        print 'Enter the corresponding number to the caluclation to be performed:';
        $calc = <stdin>;
        chomp $calc;
        print 'Please enter the first value: ';
        $A = <stdin>;
        chomp $A;
        print 'Please enter the second value: ';
        $B = <stdin>;
        chomp $B;
        
        if($calc == 1)
            {
            $answer = $A + $B;
            }
        elsif($calc == 2)
            {
            $answer = $A - $B;    
            }
        elsif($calc == 3)
            {
            $answer = $A * $B;
            }    
        elsif($calc == 4)
            {
            $answer = $A / $B;
            }    
        elsif($calc == 5)
            {
            $answer = $A ** $B;
            }
        elsif$4calc == 6)
            {
            $answer = $A % $B;
            }
        print "The answer is $answer .";
        }
    print 'Would you like to perform another calculation? Please Type y or n';
    $run = <stdin>;
    chomp = $run;
    }


print 'The application is now terminated.';