eXorithm – Execute Algorithm: View / Run Algorithm simple_calculator

Logo Beta

function simple_calculator ($number1$operator$number2
{
  // calculator
  
  switch ($operator) {
    case "plus"
      $res = $number1$number2
      break
    case "minus"
      $res = $number1$number2
      break
    case "times"
      $res = $number1$number2
      break
    case "divided by"
      $res = $number1$number2
      break
    default
      $res = 0;
  }
  
  return $res