Facebook
From Pavan Sengar, 2 Years ago, written in PHP.
This paste is a reply to Basic Calculator from RealBlocks - go back
Embed
Viewing differences between Basic Calculator and Re: Basic Calculator

<?php

class Calculator
{
         public static function add($a, $b)
        {
                
add(...$numbers)
 {
       $total = 0;
        foreach($numbers as $number){
            if(is_numeric($number)){
               $total += $number;
            }else{
                throw new Exception ("All the number must be numeric")
            }
        }
  
return $a + $b;
        }

        
$total;
 }

 
public static function divide($a, $b)
        {
                
$b)
 {
  $total = 0;
        if(is_numeric($a) && is_numeric($b)){
          $total = $a / $b;
        }else{
          throw new Exception ("All the number must be numeric")
        }
      
  
return $a / $b;
        
$total;
 
}
}