Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CalculatorFunction {
- public int operation(int a, int b , String s){
- switch (s) {
- case "+":
- return a + b;
- case "-":
- return a - b;
- case "*":
- return a * b;
- case "/":
- if (b != 0){
- return a / b;
- }
- else {
- System.out.println("You can`t divide by 0");
- }
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement