-
-
Save parzibyte/740ec479e8a506f8ca772639201c4639 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimpleCalculator { | |
public static double calculate(double operand1, double operand2, char operator) { | |
switch (operator) { | |
case '+': | |
return operand1 + operand2; | |
case '-': | |
return operand1 - operand2; | |
case '*': | |
return operand1 * operand2; | |
case '/': | |
return operand1 / operand2; | |
case '%': | |
return operand1 % operand2; | |
case '^': | |
return Math.pow(operand1, operand2); | |
} | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment