diff --git a/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/MainActivity.java b/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/MainActivity.java index b41393f1..bbfff066 100644 --- a/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/MainActivity.java +++ b/app/src/main/java/calculator/simplemobiletools/com/simple_calculator/MainActivity.java @@ -25,6 +25,7 @@ public class MainActivity extends AppCompatActivity { private static final int MULTIPLY = 4; private static final int DIVIDE = 5; private static final int MODULO = 6; + private static final int POWER = 7; @Override protected void onCreate(Bundle savedInstanceState) { @@ -128,6 +129,11 @@ public class MainActivity extends AppCompatActivity { lastKey = EQUALS; } + @OnClick(R.id.btn_power) + public void powerClicked() { + handleOperation(POWER); + } + public void decimalClicked() { String value = getDisplayedNumber(); if (!value.contains(".")) @@ -164,6 +170,9 @@ public class MainActivity extends AppCompatActivity { case MODULO: moduloNumbers(); break; + case POWER: + updateResult(Math.pow(baseValue, secondValue)); + break; default: break; }