Advertisement
AchkataJo

Untitled

Dec 13th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. public class CalculatorFunction {
  2.  
  3. public int operation(int a, int b , String s){
  4. switch (s) {
  5. case "+":
  6. return a + b;
  7. case "-":
  8. return a - b;
  9. case "*":
  10. return a * b;
  11. case "/":
  12. if (b != 0){
  13. return a / b;
  14. }
  15. else {
  16. System.out.println("You can`t divide by 0");
  17. }
  18.  
  19. }
  20. return 0;
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement