Skip to main content

Android Scientific Calculator

calculator SciFi

Click here to download a powerful android scientific calculator from mogtech.

Click to watch how the calculator was created.

 Following the video tutorial, you will learn how to successfully work with android layouts.
Click to watch the video tutorial on how the calculator was created.


You can find nice services here. Click to see more 👌



The XML file for this calculator is below

<?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:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="horizontal"
    tools:context="com.wordpress.mogtechsoftworks.scificalculator.MainActivity">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:orientation="vertical">

        <EditText
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:inputType="number"
            android:ems="10"
            android:id="@+id/editText"
            android:layout_weight="10"
            android:hint="Enter a number"
            android:textSize="25dp"
            android:layout_gravity="top" />

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:weightSum="1"
            android:layout_weight="1.5"
            android:layout_gravity="top|left|bottom|right"
            android:gravity="fill_horizontal|start|fill_vertical|end">

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:weightSum="0"
                android:layout_gravity="top|left|bottom|right"
                android:layout_weight="0.13">

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="1"
                    android:id="@+id/btn1"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_weight="1"
                    android:layout_gravity="top|left|bottom|right" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="2"
                    android:id="@+id/btn2"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_weight="1"
                    android:layout_gravity="top|left|bottom|right" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="3"
                    android:id="@+id/btn3"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_weight="1"
                    android:layout_gravity="top|left|bottom|right" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="4"
                    android:id="@+id/btn4"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_weight="1"
                    android:layout_gravity="top|left|bottom|right" />

            </LinearLayout>
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_gravity="top|left|bottom|center|right"
                android:weightSum="0"
                android:layout_weight="0.13">

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="5"
                    android:id="@+id/btn5"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_gravity="left"
                    android:layout_weight="1" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="6"
                    android:id="@+id/btn6"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_gravity="left"
                    android:layout_weight="1" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="7"
                    android:id="@+id/btn7"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_gravity="left"
                    android:layout_weight="1" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="8"
                    android:id="@+id/btn8"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_gravity="left"
                    android:layout_weight="1" />

            </LinearLayout>
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_gravity="top|left|bottom|center|right"
                android:weightSum="0"
                android:layout_weight="0.13">

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="9"
                    android:id="@+id/btn9"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:layout_weight="1"
                    android:layout_gravity="left"
                    android:gravity="center_vertical|center_horizontal" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="0"
                    android:id="@+id/btn0"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:layout_weight="1"
                    android:layout_gravity="left"
                    android:gravity="center_vertical|center_horizontal" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="."
                    android:id="@+id/dot"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:layout_weight="1"
                    android:layout_gravity="left"
                    android:gravity="center_vertical|center_horizontal" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="Ce"
                    android:id="@+id/Ce"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:layout_weight="1"
                    android:layout_gravity="left"
                    android:gravity="center_vertical|center_horizontal" />

            </LinearLayout>
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_gravity="top|left|bottom|center|right"
                android:weightSum="0"
                android:layout_weight="0.13">

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="+"
                    android:id="@+id/add"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_weight="1"
                    android:layout_gravity="left" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="-"
                    android:id="@+id/subt"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_weight="1"
                    android:layout_gravity="left" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="*"
                    android:id="@+id/mult"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_weight="1"
                    android:layout_gravity="left" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="C"
                    android:id="@+id/C"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_weight="1"
                    android:layout_gravity="left" />

            </LinearLayout>
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_gravity="top|left|bottom|center|right"
                android:weightSum="0"
                android:layout_weight="0.13">

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="/"
                    android:id="@+id/div"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:layout_gravity="left"
                    android:layout_weight="1"
                    android:gravity="center_vertical|center_horizontal" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="Cos"
                    android:id="@+id/cos"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:layout_gravity="left"
                    android:layout_weight="1"
                    android:gravity="center_vertical|center_horizontal" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="Sin"
                    android:id="@+id/sin"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:layout_gravity="left"
                    android:layout_weight="1"
                    android:gravity="center_vertical|center_horizontal" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="Tan"
                    android:id="@+id/tan"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:layout_gravity="left"
                    android:layout_weight="1"
                    android:gravity="center_vertical|center_horizontal" />

            </LinearLayout>
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_gravity="top|left|bottom|center|right"
                android:weightSum="0"
                android:layout_weight="0.13">

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="Sinh"
                    android:id="@+id/sinh"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_gravity="left"
                    android:layout_weight="1" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="Cosh"
                    android:id="@+id/cosh"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_gravity="left"
                    android:layout_weight="1" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="Tanh"
                    android:id="@+id/tanh"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_gravity="left"
                    android:layout_weight="1" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="Log"
                    android:id="@+id/log"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_gravity="left"
                    android:layout_weight="1" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_gravity="top|left|bottom|center|right"
                android:weightSum="0"
                android:layout_weight="0.13">

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="Pow"
                    android:id="@+id/exp"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:layout_gravity="left"
                    android:layout_weight="1"
                    android:gravity="center_vertical|center_horizontal" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="Sqrt"
                    android:id="@+id/sqrt"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:layout_gravity="left"
                    android:layout_weight="1"
                    android:gravity="center_vertical|center_horizontal" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="Rad"
                    android:id="@+id/rad"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:layout_gravity="left"
                    android:layout_weight="1"
                    android:gravity="center_vertical|center_horizontal" />

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="Deg"
                    android:id="@+id/deg"
                    android:textSize="25dp"
                    android:width="90dp"
                    android:layout_gravity="left"
                    android:layout_weight="1"
                    android:gravity="center_vertical|center_horizontal" />



            </LinearLayout>
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_gravity="top|left|bottom|center|right"
                android:weightSum="0"
                android:layout_weight="0.13">

                <Button
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:text="%"
                    android:id="@+id/perc"
                    android:textSize="25dp"
                    android:layout_gravity="left"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_weight="3" />

               <Button
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:text="="
                    android:id="@+id/equals"
                    android:textStyle="bold"
                    android:textSize="30dp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_gravity="left"
                   android:layout_weight="1" />
            </LinearLayout>

        </LinearLayout>
    </LinearLayout>
</RelativeLayout>
 
 You can find nice services here. Click to see more 👌 
 
 

The Java code is
 
package com.wordpress.mogtechsoftworks.scificalculator;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    EditText txtAnswer;
    Button btn1, btn2,btn3, btn4,btn5,btn6,btn7,btn8,btn9,btn0,btnStop,btnTanh,btnCosh,btnCoth,btnSqr;
    Button btnAdd, btnSubt,btnMult,btnEquals,btnSin,btnCos,btnTan,btnCe,btnC,btnDiv,btnPerc,btnLog,btnReg, btnDeg,btnExp;
    Double Answer; Double Val2 =0.0; Double Val1 =0.1;
    String Sign; boolean solved = false; boolean solvedWithouEqu = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        AddOnclickListenersForButton();
    }
    private void AddOnclickListenersForButton(){
        txtAnswer = (EditText) findViewById(R.id.editText);
        btn0=(Button)findViewById(R.id.btn0);btn1=(Button)findViewById(R.id.btn1);
        btn2=(Button)findViewById(R.id.btn2);btn3=(Button)findViewById(R.id.btn3);
        btn4=(Button)findViewById(R.id.btn4);btn5=(Button)findViewById(R.id.btn5);
        btn6=(Button)findViewById(R.id.btn6);btn7=(Button)findViewById(R.id.btn7);
        btn9=(Button)findViewById(R.id.btn9);btn8=(Button)findViewById(R.id.btn8);
        btnC=(Button)findViewById(R.id.C);btnCe=(Button)findViewById(R.id.Ce);
        btnCos=(Button)findViewById(R.id.cos);btnTan=(Button)findViewById(R.id.tan);
        btnEquals=(Button)findViewById(R.id.equals);btnPerc=(Button)findViewById(R.id.perc);
        btnDiv=(Button)findViewById(R.id.div);btnAdd=(Button)findViewById(R.id.add);
        btnSubt=(Button)findViewById(R.id.subt);btnLog=(Button)findViewById(R.id.log);
        btnStop=(Button)findViewById(R.id.dot);btnMult=(Button)findViewById(R.id.mult);
        btnTanh=(Button)findViewById(R.id.tanh);btnCoth=(Button)findViewById(R.id.sinh);
        btnCosh=(Button)findViewById(R.id.cosh);btnSqr=(Button)findViewById(R.id.sqrt);
        btnSin=(Button)findViewById(R.id.sin);btnExp=(Button)findViewById(R.id.exp);
        btnDeg=(Button)findViewById(R.id.deg);btnReg=(Button)findViewById(R.id.rad);


        btn0.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(solved==true || solvedWithouEqu==true){txtAnswer.setText(""); solved=false;solvedWithouEqu=false;}
                txtAnswer.setText(txtAnswer.getText().toString() +  btn0.getText().toString());
            }
        });
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(solved==true || solvedWithouEqu==true){txtAnswer.setText(""); solved=false;solvedWithouEqu=false;}
                txtAnswer.setText(txtAnswer.getText().toString() +  btn1.getText().toString());
            }
        });
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(solved==true || solvedWithouEqu==true){txtAnswer.setText(""); solved=false;solvedWithouEqu=false;}
                txtAnswer.setText(txtAnswer.getText().toString() +  btn2.getText().toString());
            }
        });
        btn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(solved==true || solvedWithouEqu==true){txtAnswer.setText(""); solved=false;solvedWithouEqu=false;}
                txtAnswer.setText(txtAnswer.getText().toString() +  btn3.getText().toString());
            }
        });
        btn4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(solved==true || solvedWithouEqu==true){txtAnswer.setText(""); solved=false;solvedWithouEqu=false;}
                txtAnswer.setText(txtAnswer.getText().toString() +  btn4.getText().toString());
            }
        });
        btn5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(solved==true || solvedWithouEqu==true){txtAnswer.setText(""); solved=false;solvedWithouEqu=false;}
                txtAnswer.setText(txtAnswer.getText().toString() +  btn5.getText().toString());
            }
        });
        btn6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(solved==true || solvedWithouEqu==true){txtAnswer.setText(""); solved=false;solvedWithouEqu=false;}
                txtAnswer.setText(txtAnswer.getText().toString() +  btn6.getText().toString());
            }
        });
        btn7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(solved==true || solvedWithouEqu==true){txtAnswer.setText(""); solved=false;solvedWithouEqu=false;}
                txtAnswer.setText(txtAnswer.getText().toString() +  btn7.getText().toString());
            }
        });
        btn8.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(solved==true || solvedWithouEqu==true){txtAnswer.setText(""); solved=false;solvedWithouEqu=false;}
                txtAnswer.setText(txtAnswer.getText().toString() +  btn8.getText().toString());
            }
        });
        btn9.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(solved==true || solvedWithouEqu==true){txtAnswer.setText(""); solved=false;solvedWithouEqu=false;}
                txtAnswer.setText(txtAnswer.getText().toString() +  btn9.getText().toString());
            }
        });
        btnStop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(solved==true || solvedWithouEqu==true){txtAnswer.setText(""); solved=false;solvedWithouEqu=false;}
                txtAnswer.setText(txtAnswer.getText().toString() +  btnStop.getText().toString());
            }
        });
        btnAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if (Val2==0.0){
                        Val1=Double.parseDouble(txtAnswer.getText().toString()) ;
                        txtAnswer.setText(""); Sign="+";Val2=Double.parseDouble("1");
                    }
                    else {
                        Val1=Val1 + Double.parseDouble(txtAnswer.getText().toString())  ;
                        txtAnswer.setText(Val1.toString()); Sign="+";solvedWithouEqu=true;}
                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }
              }
        });
        btnSubt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if (Val2==0.0){
                        Val1=Double.parseDouble(txtAnswer.getText().toString()) ;
                        txtAnswer.setText(""); Sign="-";Val2=Double.parseDouble("1");
                    }
                    else {
                        Val1=Val1 - Double.parseDouble(txtAnswer.getText().toString())  ;
                        txtAnswer.setText(Val1.toString()); Sign="-";solvedWithouEqu=true;
                    }
                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });
        btnC.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                txtAnswer.setText("");Val2=0.0; Val1=0.0;
            }
        });
        btnCe.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    int i= txtAnswer.getText().length();
                    txtAnswer.setText(txtAnswer.getText().subSequence(0,i-1));
                    if (txtAnswer.getText()==null){Val1=0.0;}
                }
                catch (Exception ex) {txtAnswer.setText("");}
                finally {

                }


            }
        });
        btnDiv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if (Val2==0.0){
                        Val1=Double.parseDouble(txtAnswer.getText().toString()) ;
                        txtAnswer.setText(""); Sign="/";Val2=Double.parseDouble("1");
                    }
                    else {
                        Val1=Val1 / Double.parseDouble(txtAnswer.getText().toString())  ;
                        txtAnswer.setText(Val1.toString()); Sign="/";solvedWithouEqu=true;
                    }
                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });
        btnMult.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if (Val2==0.0){
                        Val1=Double.parseDouble(txtAnswer.getText().toString()) ;
                        txtAnswer.setText(""); Sign="*";Val2=Double.parseDouble("1");
                    }
                    else {
                        Val1=Val1 * Double.parseDouble(txtAnswer.getText().toString())  ;
                        txtAnswer.setText(Val1.toString()); Sign="*";solvedWithouEqu=true;
                    }
                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });
        btnExp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if (Val2==0.0){
                        Val1=Double.parseDouble(txtAnswer.getText().toString()) ;
                        txtAnswer.setText(""); Sign="^";Val2=Double.parseDouble("1");
                    }
                    else {
                        Val1=Math.pow(Val1, Double.parseDouble(txtAnswer.getText().toString()))  ;
                        txtAnswer.setText(Val1.toString()); Sign="^";solvedWithouEqu=true;
                    }
                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });
        btnPerc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    if (Val2==0.0){
                        Val1=Double.parseDouble(txtAnswer.getText().toString()) ;
                        txtAnswer.setText(""); Sign="%";Val2=Double.parseDouble("1");
                    }
                    else {
                        Val1 = Val1 * (Double.parseDouble(txtAnswer.getText().toString()) / 100);
                        txtAnswer.setText(Val1.toString());
                        Sign = "%";
                        solvedWithouEqu = true;
                    }
                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });
        btnLog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                try{
                    Answer=Math.log(Double.parseDouble(txtAnswer.getText().toString()));
                    Val2=0.0; Val1=0.0;
                    txtAnswer.setText(Answer.toString());solvedWithouEqu=true;
                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });
        btnSin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                try{
                    Answer=Math.sin(Double.parseDouble(txtAnswer.getText().toString()));
                    Val2=0.0; Val1=0.0;
                    txtAnswer.setText(Answer.toString());solvedWithouEqu=true;
                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });
        btnCos.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                try{

                    Answer=Math.cos(Double.parseDouble(txtAnswer.getText().toString()));
                    Val2=0.0; Val1=0.0;
                    txtAnswer.setText(Answer.toString());solvedWithouEqu=true;
                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });
        btnTan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                try{
                    Answer=Math.tan(Double.parseDouble(txtAnswer.getText().toString()));
                    Val2=0.0; Val1=0.0;
                    txtAnswer.setText(Answer.toString());solvedWithouEqu=true;

                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });
        btnCoth.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                try{
                    Answer=Math.sinh(Double.parseDouble(txtAnswer.getText().toString()));
                    Val2=0.0; Val1=0.0;
                    txtAnswer.setText(Answer.toString());solvedWithouEqu=true;

                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally { }

            }
        });
        btnCosh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                try{
                    Answer=Math.cosh(Double.parseDouble(txtAnswer.getText().toString()));
                    Val2=0.0; Val1=0.0;
                    txtAnswer.setText(Answer.toString());solvedWithouEqu=true;
                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally { }

            }
        });
        btnTanh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                try{
                    Answer=Math.tanh(Double.parseDouble(txtAnswer.getText().toString()));
                    Val2=0.0; Val1=0.0;
                    txtAnswer.setText(Answer.toString());solvedWithouEqu=true;

                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });

        btnReg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                try{
                    Answer=Math.toRadians(Double.parseDouble(txtAnswer.getText().toString()));
                    Val2=0.0; Val1=0.0;
                    txtAnswer.setText(Answer.toString());solvedWithouEqu=true;
                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });

        btnDeg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                try{
                    Answer=Math.toDegrees(Double.parseDouble(txtAnswer.getText().toString()));
                    Val2=0.0; Val1=0.0;
                    txtAnswer.setText(Answer.toString());solvedWithouEqu=true;

                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });

        btnEquals.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try{
                    Val2=Double.parseDouble(txtAnswer.getText().toString());
                    switch (Sign){
                        case  "+":Answer=Val1 + Val2; break;
                        case  "-":Answer=Val1 - Val2; break;
                        case  "*":Answer=Val1 * Val2; break;
                        case  "/":Answer=Val1 / Val2; break;
                        case  "%":Answer=Val1 * (Val2/100); break;
                        case  "^":Answer=Math.pow(Val1, Val2); break;
                        default:
                    }
                    txtAnswer.setText(String.format(Answer.toString()));
                    Val2=0.0; Val1=0.0; solved=true; Sign="";
                }
                catch (Exception ex) {txtAnswer.setText("0");}
                finally {

                }

            }
        });

    }
}
 


You can find nice services here. Click to see more 👌 

To download the entire project click HERE.

Contact me for your android apps mogtechsoftworks@gmail.com

Comments

  1. Punta Cana Casino Resort - Mapyro
    Find your 시흥 출장안마 way around the casino, find where everything is located, and what is there to 논산 출장안마 do and do when it 상주 출장샵 comes 부천 출장마사지 to gaming. Rating: 7.3/10 · ‎1,755 부산광역 출장안마 reviews

    ReplyDelete

Post a Comment

Popular posts from this blog

BEST JAMB COMPUTER BASED TEST 2017

MOGTECH Jamb CBT is out with the aim of helping Jamb Candidates make a better result. Practice, they say makes perfect. With this software a student can test his performance so far and as well read through past Jamb Questions and Answers. This software helps a candidate to make jamb and score high score in jamb 2017. It contains the following subjects; English Geography Physics Chemistry Economics CRS Account Commerce Literature in English Biology Visit this site always to see updated version! The new version now has more subjects and a better grading system. Click to download a version for windows xp, vista & 7. This version only requires Ms Access. click to get Ms Access Here . Click here to download a version for windows 8 and 10 computers . This version requires dot net framework which is present in windows 8 and above. It also requires Ms Access. If you don’t have it in your computer,  click Here to get . Also see YouTube video on how it works ...