Facebook Twitter Instagram
    DeepCrazyWorld
    Facebook Twitter Instagram Pinterest YouTube
    • FLUTTER
      • FLUTTER APP
        • QRCode
        • Quiz App
        • Chat GPT
        • PDF App
        • News App
        • Fitness App
        • Weather App
        • BMI Calculator
        • GAME APP
        • Ecommerce App
        • wallpaper App
        • Finance app
        • Chat App
        • Wallet App
        • Taxi App
        • Quran app
        • Music player app
      • FLUTTER UI
        • Splash Screen
        • Onboarding Screen
        • Login Screen
        • Card Design
        • Drawer
    • PROJECT
      • Android Projects
      • College Projects
      • FLUTTER APP
      • Project Ideas
      • PHP Projects
      • Python Projects
    • SOURCE CODE
    • ANDROID
      • ANDROID APP
      • GAME APP
      • ANDROID STUDIO
    • MCQ
      • AKTU MCQ
        • RPA MCQ
        • COA MCQ
        • HPC MCQ
        • SPM MCQ
        • Renewable Energy All MCQ
        • Data Compression MCQ
        • Data Structure MCQ
        • Digital Image Processing MCQ
        • Software Engineering MCQ
        • Machine Learning MCQ
        • Artificial Intelligence MCQ
      • D PHARMA MCQ
        • Pharmaceutics – I MCQ
        • Pharmacognosy MCQ
        • Pharmaceutical Chemistry MCQ
        • Biochemistry and Clinical Pathology MCQ
        • Human Anatomy and Physiology MCQ
        • Heath Education and Community Pharmacy MCQ
    • INTERVIEW QUESTIONS
      • Flutter Interview Questions
      • INTERVIEW QUESTIONS
      • Python Interview Questions
      • Coding ninjas solution
    • MORE
      • WORDPRESS
        • SEO
        • TOP 10 WORDPRESS THEME
      • PRODUCTIVITY
      • Program
      • QUOTES
    DeepCrazyWorld
    Home»ANDROID»How to make Calculator app in android studio source code
    ANDROID

    How to make Calculator app in android studio source code

    DeepikaBy DeepikaOctober 17, 2019Updated:April 17, 2023No Comments5 Mins Read

    How To create Simple Calculator Android App in Android Studio like Addition subtraction , multiplication and division etc.

    In this Section we will be saying that google play store is very good platform to store our App on Play Store .and create a simple calculator app ,We can easily handle our apps and Update our App Time to Time this simple calculator app and Google play store are not take much more time in Update .For More You Can Download and Install My All App on Google Play Store

    <img decoding=
    Admob Ads

    Visit my Google Play Store Apps Click on this Link

    Visit For Browser 5 G App On google Play Store>>>>>>>>>>

    This My Creative App Click on DeepCrazyWorld App>>>>>>>>>>>

    To Solve Your Math Calculation Math Solve App >>>>>

    Spinner Bottle Game App>>>>>>>>>>>>>>>>>>>>>

    This News Nation App News7on>>>>>>>>>>>>>>

    Shopping App ZampKart >>>>>>>>>>>>>>>>>>>

    Math Equation Solving App>>>>>>>>>>>>>>>>>>>

    Event Basis Picture LovingCaring143 App>>>>>>>>>

    Here This Blogger Site App to Explore Your Knowledge Download all this Apps By Google Play Store My Blogger Site App Download And Install. create simple calculator android app

    Click on Link CrazyCoder>>>>>>>>>>

    Table of Contents

    Toggle
    • How To create Scientific calculator Android App in Android Studio
    • MainActivity.java
    • step wise xml file calculator app android studio
    • activity_main.xml
    • Add Ad MOB AD In Android App YouTube Video
    • Conclusion
      • Cheers!
    • READ MORE.

    How To create Scientific calculator Android App in Android Studio

    MainActivity.java

    package com.deep.calc;
    
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    public class MainActivity extends AppCompatActivity {
    
        Button button0, button1, button2, button3, button4, button5, button6,
                button7, button8, button9, buttonAdd, buttonSub, buttonDivision,
                buttonMul, button10, buttonC, buttonEqual;
        EditText deepEditText;
    
        float mValueOne, mValueTwo;
    
        boolean deepAddition, mSubtract, deepMultiplication, deepDivision;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            button0 = (Button) findViewById(R.id.button0);
            button1 = (Button) findViewById(R.id.button1);
            button2 = (Button) findViewById(R.id.button2);
            button3 = (Button) findViewById(R.id.button3);
            button4 = (Button) findViewById(R.id.button4);
            button5 = (Button) findViewById(R.id.button5);
            button6 = (Button) findViewById(R.id.button6);
            button7 = (Button) findViewById(R.id.button7);
            button8 = (Button) findViewById(R.id.button8);
            button9 = (Button) findViewById(R.id.button9);
            button10 = (Button) findViewById(R.id.button10);
            buttonAdd = (Button) findViewById(R.id.buttonadd);
            buttonSub = (Button) findViewById(R.id.buttonsub);
            buttonMul = (Button) findViewById(R.id.buttonmul);
            buttonDivision = (Button) findViewById(R.id.buttondiv);
            buttonC = (Button) findViewById(R.id.buttonC);
            buttonEqual = (Button) findViewById(R.id.buttoneql);
            deepEditText = (EditText) findViewById(R.id.edt1);
    
    
            button1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deepEditText.setText(deepEditText.getText() + "1");
                }
            });
    
            button2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deepEditText.setText(deepEditText.getText() + "2");
                }
            });
    
            button3.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deepEditText.setText(deepEditText.getText() + "3");
                }
            });
    
            button4.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deepEditText.setText(deepEditText.getText() + "4");
                }
            });
    
            button5.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deepEditText.setText(deepEditText.getText() + "5");
                }
            });
    
            button6.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deepEditText.setText(deepEditText.getText() + "6");
                }
            });
    
            button7.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deepEditText.setText(deepEditText.getText() + "7");
                }
            });
    
            button8.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deepEditText.setText(deepEditText.getText() + "8");
                }
            });
    
            button9.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deepEditText.setText(deepEditText.getText() + "9");
                }
            });
    
            button0.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deepEditText.setText(deepEditText.getText() + "0");
                }
            });
    
            buttonAdd.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
    
                    if (deepEditText == null) {
                        deepEditText.setText("");
                    } else {
                        mValueOne = Float.parseFloat(deepEditText.getText() + "");
                        deepAddition = true;
                        deepEditText.setText(null);
                    }
                }
            });
    
            buttonSub.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mValueOne = Float.parseFloat(deepEditText.getText() + "");
                    mSubtract = true;
                    deepEditText.setText(null);
                }
            });
    
            buttonMul.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mValueOne = Float.parseFloat(deepEditText.getText() + "");
                    deepMultiplication = true;
                    deepEditText.setText(null);
                }
            });
    
            buttonDivision.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mValueOne = Float.parseFloat(deepEditText.getText() + "");
                    deepDivision = true;
                    deepEditText.setText(null);
                }
            });
    
            buttonEqual.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mValueTwo = Float.parseFloat(deepEditText.getText() + "");
    
                    if (deepAddition == true) {
                        deepEditText.setText(mValueOne + mValueTwo + "");
                        deepAddition = false;
                    }
    
                    if (mSubtract == true) {
                        deepEditText.setText(mValueOne - mValueTwo + "");
                        mSubtract = false;
                    }
    
                    if (deepMultiplication == true) {
                        deepEditText.setText(mValueOne * mValueTwo + "");
                        deepMultiplication = false;
                    }
    
                    if (deepDivision == true) {
                        deepEditText.setText(mValueOne / mValueTwo + "");
                        deepDivision = false;
                    }
                }
            });
    
            buttonC.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deepEditText.setText("");
                }
            });
    
            button10.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    deepEditText.setText(deepEditText.getText() + ".");
                }
            });
        }
    }

    step wise xml file calculator app android studio

    Again that we are well versed with Activity, Layout, Views etc its time to get our hands dirty, and create our second application. This application will have a science quiz app, and user will have option to answer in True or False. Based on what the user enters, we will show the user, whether they selected the correct option or not by simply showing a message saying Correct or Incorrect.

    For Quiz App Open Android Studio and go to File → New → New Project. In the New Project window, enter the Application Name as Quiz and company domain as com.technic.calc and Click on Next.

    activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/relative1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
    
        <EditText
            android:id="@+id/edt1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    
    
        <Button
            android:id="@+id/button1"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/edt1"
            android:layout_alignEnd="@+id/button4"
            android:layout_alignRight="@+id/button4"
            android:layout_marginTop="94dp"
            android:text="1" />
    
        <Button
            android:id="@+id/button2"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/button1"
            android:layout_toStartOf="@+id/button3"
            android:layout_toLeftOf="@+id/button3"
            android:text="2" />
    
        <Button
            android:id="@+id/button3"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/button2"
            android:layout_centerHorizontal="true"
            android:text="3" />
    
        <Button
            android:id="@+id/button4"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button1"
            android:layout_toLeftOf="@+id/button2"
            android:text="4" />
    
        <Button
            android:id="@+id/button5"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignStart="@+id/button2"
            android:layout_alignLeft="@+id/button2"
            android:layout_alignBottom="@+id/button4"
            android:text="5" />
    
        <Button
            android:id="@+id/button6"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button3"
            android:layout_alignStart="@+id/button3"
            android:layout_alignLeft="@+id/button3"
            android:text="6" />
    
        <Button
            android:id="@+id/button7"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button4"
            android:layout_toLeftOf="@+id/button2"
            android:text="7" />
    
        <Button
            android:id="@+id/button8"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button5"
            android:layout_alignStart="@+id/button5"
            android:layout_alignLeft="@+id/button5"
            android:text="8" />
    
        <Button
            android:id="@+id/button9"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button6"
            android:layout_alignStart="@+id/button6"
            android:layout_alignLeft="@+id/button6"
            android:text="9" />
    
        <Button
            android:id="@+id/buttonadd"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/button3"
            android:layout_alignEnd="@+id/edt1"
            android:layout_alignRight="@+id/edt1"
            android:layout_marginStart="46dp"
            android:layout_marginLeft="46dp"
            android:layout_toRightOf="@+id/button3"
            android:text="+" />
    
        <Button
            android:id="@+id/buttonsub"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/buttonadd"
            android:layout_alignStart="@+id/buttonadd"
            android:layout_alignLeft="@+id/buttonadd"
            android:layout_alignEnd="@+id/buttonadd"
            android:layout_alignRight="@+id/buttonadd"
            android:text="-" />
    
        <Button
            android:id="@+id/buttonmul"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/buttonsub"
            android:layout_alignStart="@+id/buttonsub"
            android:layout_alignLeft="@+id/buttonsub"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:text="*" />
    
        <Button
            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button7"
            android:layout_toLeftOf="@+id/button2"
            android:text="." />
    
        <Button
            android:id="@+id/button0"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button8"
            android:layout_alignStart="@+id/button8"
            android:layout_alignLeft="@+id/button8"
            android:text="0" />
    
        <Button
            android:id="@+id/buttonC"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button9"
            android:layout_alignStart="@+id/button9"
            android:layout_alignLeft="@+id/button9"
            android:text="C" />
    
        <Button
            android:id="@+id/buttondiv"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/buttonmul"
            android:layout_alignStart="@+id/buttonmul"
            android:layout_alignLeft="@+id/buttonmul"
            android:layout_alignEnd="@+id/buttonmul"
            android:layout_alignRight="@+id/buttonmul"
            android:text="/" />
    
        <Button
            android:id="@+id/buttoneql"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button0"
            android:layout_alignStart="@+id/button10"
            android:layout_alignLeft="@+id/button10"
            android:layout_alignEnd="@+id/buttondiv"
            android:layout_alignRight="@+id/buttondiv"
            android:layout_marginTop="37dp"
            android:text="=" />
    
    </RelativeLayout>

    Add Ad MOB AD In Android App YouTube Video

    Conclusion

    We have successfully created a Calculator app in android studio


    Cheers!

    READ MORE.

    Share. Facebook Twitter LinkedIn WhatsApp Telegram Pinterest Reddit Email
    Previous ArticleWonder share Filmora 9 Full version Crack download 2023 { key+host }
    Next Article Android Game Development tutorial for biggners | source code free

    Related Posts

    Flutter Calculator app for seamless mathematical operations

    Calculator App 3 Mins Read

    How to Make Car Racing Game App with Android Studio

    ANDROID 2 Mins Read

    OOP’s Concept Code – Basic operations and Relational Operators

    ANDROID STUDIO 3 Mins Read

    Java Program , Loop , Basic operations, Relational Operators

    ANDROID STUDIO 3 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • Implementing a Dynamic FAQ Screen UI in Flutter Using ExpansionTile March 29, 2025
    • Creating an Instruction UI Screen in Flutter Application March 29, 2025
    • Animated Backgrounds in Flutter: A Complete Guide March 15, 2025
    • How to make Diary App using flutter stepwise using getx August 31, 2024
    • How to Create Music Player UI screen with fully functional in flutter August 30, 2024
    • How to make ListView Builder Ui in flutter with Source Code August 29, 2024
    • Create a TabBar View in flutter with fully functional stepwise August 28, 2024
    • How to create TabBar view in flutter with source code step wise August 27, 2024
    • How to make Heart rate measure app with Flutter stepwise August 26, 2024
    • How to make ChatGpt App in flutter with source code Stepwise August 25, 2024
    Facebook Twitter Instagram Pinterest YouTube
    • About
    • Contact
    • Disclaimer
    • Privacy Policy
    Copyright by DeepCrazyWorld © 2025

    Type above and press Enter to search. Press Esc to cancel.