public class Model { public float beregn(float x, float y, String operasjon) { switch (operasjon) { case "+": return x + y; case "-": return x - y; case "*": return x * y; case "/": if (y > 0) { return x / y; } else { return 0; } default: return 0; } } }