How to Build a Simple Calculator in Android

In android Simple Calculator is used when we want to addition ,subtraction,division,multiplication  of the two value and get the answer.

simple Calculator

  • We can create a Calculator instance by declaring it inside a layout(XML file) or by instantiating it programmatically(Java Class) We Will See The Example Of The Calculator In Bellow.

Example Of Calculator:

Step 1: Create a new project and name it what you want to give

  • Select File -> New -> New Project. Fill the forms and click “Finish” button.

Step 2: Open res -> layout -> xml (or) activity_main.xml and add following code. Here we will create a Calculator  in between Linear Layout.

Step 3: Open app -> java -> package and open MainActivity.java and add the following code. Here we will display the code of the calculator.

Output :

Now run the app in Emulator and click on the button. You will see Simple Calculator.

simple Calculator

Leave a Reply

Your email address will not be published. Required fields are marked *