package simplejavacalculator;

public class Calculator {
    public enum BiOperatorModes {
        normal, add, minus, multiply, divide
    }

    public enum MonoOperatorModes {
        square, squareRoot, oneDevidedBy, cos, sin, tan
    }

    private Double num1, num2;
    private BiOperatorModes mode = BiOperatorModes.normal;

    private Double calculateBiImpl() {
        if (mode == BiOperatorModes.normal) {
            return num2;
        }
        if (mode == BiOperatorModes.add) {
            return num1 + num2;
        }
        if (mode == BiOperatorModes.minus) {
            return num1 - num2;
        }
        if (mode == BiOperatorModes.multiply) {
            return num1 * num2;
        }
        if (mode == BiOperatorModes.divide) {
            return num1 / num2;
        }

        // never reach
        throw new Error();
    }

    public Double calculateBi(BiOperatorModes newMode, Double num) {
        if (mode == BiOperatorModes.normal) {
            num2 = 0.0;
            num1 = num;
            mode = newMode;
            return Double.NaN;
        } else {
            num2 = num;
            num1 = calculateBiImpl();
            mode = newMode;
            return num1;
        }
    }

    public Double calculateEqual(Double num) {
        return calculateBi(BiOperatorModes.normal, num);
    }

    public Double reset() {
        num2 = 0.0;
        num1 = 0.0;
        mode = BiOperatorModes.normal;

        return Double.NaN;
    }

    public Double calculateMono(MonoOperatorModes newMode, Double num) {
        if (newMode == MonoOperatorModes.square) {
            return num * num;
        }
        if (newMode == MonoOperatorModes.squareRoot) {
            return Math.sqrt(num);
        }
        if (newMode == MonoOperatorModes.oneDevidedBy) {
            return 1 / num;
        }
        if (newMode == MonoOperatorModes.cos) {
            return Math.cos(num);
        }
        if (newMode == MonoOperatorModes.sin) {
            return Math.sin(num);
        }
        if (newMode == MonoOperatorModes.tan) {
            return Math.tan(num);
        }

        // never reach
        throw new Error();
    }

}

@@ -24,16 +24,121 @@
 lator;%0A%0A
+import static java.lang.Math.log;%0Aimport static java.lang.Math.log10;%0Aimport static java.lang.Math.pow;%0A%0A
 public c
@@ -233,16 +233,29 @@
 , divide
+ , xpowerofy 
 %0A    %7D%0A%0A
@@ -345,16 +345,28 @@
 sin, tan
+ ,log , rate
 %0A    %7D%0A%0A
@@ -917,32 +917,126 @@
  num2;%0A        %7D
+%0A        if (mode == BiOperatorModes.xpowerofy) %7B%0A            return pow(num1,num2);%0A        %7D
 %0A%0A        // nev
@@ -2329,32 +2329,217 @@
 num);%0A        %7D%0A
+        if (newMode == MonoOperatorModes.log) %7B%0A            return log10(num);%0A        %7D%0A        if (newMode == MonoOperatorModes.rate) %7B%0A           return num/100;%0A        %7D%0A        %0A%0A
 %0A        // neve

Update Calculator.java