Calculator

mail@pastecode.io avatar
unknown
php
2 years ago
793 B
8
Indexable
<?php
    while(1){
        echo "FirstNum : " ."\n" ;
        $FirstNum = readline();
        echo "SecondNum :" . "\n" ;
        $SecondNum = readline();
        echo "Choose a Function :" . "\n" ;
        $n = readline();
        if( $n == 1){
            $R = $FirstNum + $SecondNum ;       
        
        }elseif($n == 2){
            $R = $FirstNum - $SecondNum ;
        
        }elseif($n == 3){
            $R = $FirstNum * $SecondNum ;
        
        }elseif($n == 4){
            $R = $FirstNum / $SecondNum ;
        
        }elseif($n == 5){
            $R = $FirstNum ** $SecondNum ;
            
        }elseif ($n == "Exit"){
           break  ;
            
        }
        echo "Result = $R" ;
        echo "\n";
        
    }


?>