Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $command = strtolower(readline());
- $a = intval(readline());
- $b = intval(readline());
- switch ($command){
- case 'add':
- $sum = printAdd($a, $b);
- echo $sum;
- break;
- case 'multiply':
- echo printMultiply($a, $b);
- break;
- case 'subtract':
- printSubtract($a, $b);
- break;
- case 'divide':
- printDivide($a, $b);
- break;
- }
- function printAdd($num1, $num2){
- $result = $num1 + $num2;
- return $result;
- }
- function printMultiply($num1, $num2){
- $result = ($num1 * $num2);
- return $result;
- }
- function printSubtract($num1, $num2){
- echo ($num1 - $num2);
- }
- function printDivide($num1, $num2){
- echo ($num1 / $num2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement