This Android App is developed by Rameshwar Gadekar.
Source code:::
##JAVA CODE ##
package com.example.a7;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
String vv = "";
String remain = "";
public static String replacingtsymbol(String rem,char sys){
StringBuilder javac= new StringBuilder();
for (int i=0;i<rem.length()-1;i++){
javac.append(rem.charAt(i));
}
javac.append(sys);
return javac.toString();
}
public static boolean isCorrect(String str) {
int var = 0;
String[] symboldata = {"+", "-", "x", "/", "%", "^","=","."};
for (int i = 0; i <= symboldata.length - 1; i++) {
if (str.endsWith(symboldata[i])) {
var += 1;
}
}
return var>0;
}
public static String afterdec(String str){ String tore=str;int indofdot=tore.indexOf(".");StringBuilder beforedot = new StringBuilder();StringBuilder afterdot= new StringBuilder();for (int i=0;i<str.length();i++){ beforedot.append(String.valueOf(tore.charAt(i)));if (tore.charAt(i)=='.'){ break; } }int ind=tore.length()-tore.indexOf('.');System.out.println(ind);if (ind >2){ for (int j=indofdot+1;j<indofdot+3;j++){ afterdot.append(String.valueOf(tore.charAt(j))); } }else { for (int j=indofdot+1;j<tore.length();j++){ afterdot.append(String.valueOf(tore.charAt(j))); } }return beforedot.toString()+afterdot.toString(); }
public static double eval(final String str) {
return new Object() {int pos = -1, ch;void nextChar() {
ch = (++pos < str.length()) ? str.charAt(pos) : -1;
}boolean eat(int charToEat) {
while (ch == ' ') nextChar();
if (ch == charToEat) { nextChar();
return true;
}return false;
}double parse() {
nextChar();double x = parseExpression();
if (pos < str.length()) throw new RuntimeException("Unexpected: " + (char)ch);
return x;
}double parseExpression() { double x = parseTerm();
for (;;) { if (eat('+')) x += parseTerm();
else if (eat('-')) x -= parseTerm();else return x;
} }double parseTerm() { double x = parseFactor();
for (;;) { if (eat('x')) x *= parseFactor();
else if (eat('/')) x /= parseFactor();
else if (eat('%')) x %= parseFactor();else return x;
} }double parseFactor() {
if (eat('+')) return parseFactor();
if (eat('-')) return -parseFactor();
double x;
int startPos = this.pos;if (eat('(')) { x = parseExpression();
eat(')'); } else if ((ch >= '0' && ch <= '9') || ch == '.') {
while ((ch >= '0' && ch <= '9') || ch == '.') nextChar();
x = Double.parseDouble(str.substring(startPos, this.pos));
} else if (ch >= 'a' && ch <= 'z') { while (ch >= 'a' && ch <= 'z') nextChar();
String func = str.substring(startPos, this.pos);x = parseFactor();
if (func.equals("sqrt")) x = Math.sqrt(x);
else if (func.equals("sin")) x = Math.sin(Math.toRadians(x));
else if (func.equals("cos")) x = Math.cos(Math.toRadians(x));
else if (func.equals("tan")) x = Math.tan(Math.toRadians(x));
else throw new RuntimeException("Unknown function: " + func);
} else { throw new RuntimeException("Unexpected: " + (char)ch);
}if (eat('^')) x = Math.pow(x, parseFactor());return x;
}}.parse(); }
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,button11;
b3=(Button) findViewById(R.id.b3);
b4=(Button) findViewById(R.id.b4);
b6=(Button) findViewById(R.id.b6);
Button button5=(Button) findViewById(R.id.button5);
@SuppressLint("CutPasteId") Button button70=(Button) findViewById(R.id.button70);
Button button6=(Button) findViewById(R.id.button6);
Button button8=(Button) findViewById(R.id.button8);
Button bb =(Button) findViewById(R.id.b);
b7=(Button) findViewById(R.id.b7);
b8=(Button) findViewById(R.id.b8);
b9=(Button) findViewById(R.id.b9);
b10=(Button) findViewById(R.id.b10);
b11=(Button) findViewById(R.id.b11);
b12=(Button) findViewById(R.id.b12);
b13=(Button) findViewById(R.id.b13);
b14=(Button) findViewById(R.id.b14);
b15=(Button) findViewById(R.id.b15);
b16=(Button) findViewById(R.id.b16);
b17=(Button) findViewById(R.id.b17);
button11=(Button) findViewById(R.id.button11);
TextView textView2=(TextView)findViewById(R.id.textView2);
final TextView textView4=(TextView)findViewById(R.id.textView4);
Button dittoimage=(Button)findViewById(R.id.dittoimage);
final TextView textView=(TextView) findViewById(R.id.textView);
dittoimage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(MainActivity.this,login.class);
startActivity(intent); }
});
textView2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"H e y D i t t o H i e e e \nW h a t s u p . . .",Toast.LENGTH_SHORT).show();
}
});
button11.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { vv=remain+"1";
textView.setText(vv);remain=vv;
}
});
b4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){
vv=remain+"^";
}else{
vv=replacingtsymbol(vv,'^'); }
textView.setText(vv);
remain=vv;
}
});
b3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"7";
textView.setText(vv);
remain=vv;
}
});bb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"4";
textView.setText(vv);
remain=vv;
}
});
b6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"8";
textView.setText(vv);
remain=vv; }
});
b7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"5";
textView.setText(vv);
remain=vv;
}
});
b8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"2";
textView.setText(vv);
remain=vv;
}
});
button70.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){
vv=remain+"%"; }else{
vv=replacingtsymbol(remain,'%'); }
textView.setText(vv);
remain=vv;
}
});
b9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"0";
textView.setText(vv);
remain=vv;
}
});
b12.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"3";
textView.setText(vv);
remain=vv;
}
});
b11.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"6";
textView.setText(vv);
remain=vv;
}
}); b10.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"9";
textView.setText(vv);
remain=vv;
}
});
b13.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){
vv=remain+"."; }else{
vv=replacingtsymbol(remain,'.'); }
textView.setText(vv);
remain=vv;
}
});b14.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){
vv=remain+"x"; }else{
vv=replacingtsymbol(remain,'x'); }
textView.setText(vv);
remain=vv;
}
});
b15.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){
vv=remain+"-";
}
else{
vv=replacingtsymbol(remain,'-'); }
textView.setText(vv);
remain=vv;
}
});
b16.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){
vv=remain+"+"; }
else{
vv=replacingtsymbol(remain,'+'); }
textView.setText(vv);
remain=vv;
}
});
b17.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isCorrect(remain)){
Toast.makeText(MainActivity.this,"Please enter operand ...",Toast.LENGTH_SHORT).show(); }
else{
String result = (String.valueOf(eval(remain)));
// textView.setText(result);
textView4.setText(result);
remain = result; }
}
});
button5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv="";
textView.setText(vv);
textView4.setText(vv);
remain=vv;
}
});
button6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StringBuilder newstring= new StringBuilder();
if (!isCorrect(vv)){
for (int i=0;i<remain.length()-1;i++){
newstring.append(remain.charAt(i)); } }
textView.setText(newstring.toString());
remain= newstring.toString(); }
});
button8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){ vv=remain+"/"; }
else{ vv=replacingtsymbol(remain,'/'); }
textView.setText(vv);
remain=vv;
}
});
}
}
## XML CODE ##
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00BCD4"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="405dp"
android:layout_height="67dp"
android:layout_marginTop="110dp"
android:alpha="0.5"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/linearLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView">
<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CDF44336"
android:text="@string/c"
android:textColor="#FFFFFF"
android:textSize="36sp"
tools:ignore="ButtonStyle" />
<Button
android:id="@+id/button6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CDF44336"
android:text="@string/gg"
android:textColor="#FFFFFF"
android:textSize="36sp"
tools:ignore="ButtonStyle" />
<Button
android:id="@+id/button70"
android:layout_width="447dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CDF44336"
android:text="@string/dfg"
android:textColor="#FFFFFF"
android:textSize="36sp"
tools:ignore="ButtonStyle" />
<Button
android:id="@+id/button8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CDF44336"
android:paddingEnd="12dp"
android:paddingRight="12dp"
android:text="@string/h"
android:textColor="#FFFFFF"
android:textSize="36sp"
tools:ignore="ButtonStyle,RtlSymmetry" />
</LinearLayout>
<TextView
android:id="@+id/textView"
android:layout_width="384dp"
android:layout_height="39dp"
android:layout_marginBottom="100dp"
android:background="#00CDDC39"
android:hint="@string/text_will_be_here"
android:textColor="#F3C94D4D"
android:textColorHint="#20FFFFFF"
android:textSize="36sp"
app:layout_constraintBottom_toTopOf="@+id/linearLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.482"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.491" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="405dp"
android:layout_height="403dp"
android:background="#9C27B0"
android:orientation="horizontal"
android:paddingBottom="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/b3"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_7"
android:textColor="#FAF7F7"
android:textSize="36sp" />
<Button
android:id="@+id/b"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_4"
android:textColor="#FAF7F7"
android:textSize="36sp" />
<Button
android:id="@+id/button11"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_1"
android:textColor="#FAF7F7"
android:textSize="36sp" />
<Button
android:id="@+id/b4"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/x_y"
android:textColor="#D3FAF7F7"
android:textSize="24sp"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="104dp"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/b6"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_8"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b7"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_5"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b8"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_2"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b9"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_0"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
</LinearLayout>
<LinearLayout
android:layout_width="102dp"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/b10"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_9"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b11"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_6"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b12"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_3"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b13"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/fg"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
</LinearLayout>
<LinearLayout
android:layout_width="111dp"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/b14"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/x"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b15"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/dr"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b16"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/adg"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b17"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/sdfg"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/textView2"
android:layout_width="301dp"
android:layout_height="26dp"
android:layout_marginTop="5dp"
android:text="@string/yui"
android:textSize="18sp"
app:fontFamily="cursive"
app:layout_constraintBottom_toTopOf="@+id/textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.118"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/textView4"
android:layout_width="387dp"
android:layout_height="66dp"
android:textColorHint="#432196F3"
android:textSize="56sp"
app:layout_constraintBottom_toTopOf="@+id/linearLayout2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/dittoimage"
android:layout_width="54dp"
android:layout_height="27dp"
android:layout_marginBottom="28dp"
android:background="#00BCD4"
android:clickable="true"
android:focusable="true"
android:scrollbarSize="0dp"
android:textSize="18sp"
app:layout_constraintBottom_toTopOf="@+id/textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
Gmail :: "rameshwarrdg@gmail.com"
##JAVA CODE ##
package com.example.a7;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
String vv = "";
String remain = "";
public static String replacingtsymbol(String rem,char sys){
StringBuilder javac= new StringBuilder();
for (int i=0;i<rem.length()-1;i++){
javac.append(rem.charAt(i));
}
javac.append(sys);
return javac.toString();
}
public static boolean isCorrect(String str) {
int var = 0;
String[] symboldata = {"+", "-", "x", "/", "%", "^","=","."};
for (int i = 0; i <= symboldata.length - 1; i++) {
if (str.endsWith(symboldata[i])) {
var += 1;
}
}
return var>0;
}
public static String afterdec(String str){ String tore=str;int indofdot=tore.indexOf(".");StringBuilder beforedot = new StringBuilder();StringBuilder afterdot= new StringBuilder();for (int i=0;i<str.length();i++){ beforedot.append(String.valueOf(tore.charAt(i)));if (tore.charAt(i)=='.'){ break; } }int ind=tore.length()-tore.indexOf('.');System.out.println(ind);if (ind >2){ for (int j=indofdot+1;j<indofdot+3;j++){ afterdot.append(String.valueOf(tore.charAt(j))); } }else { for (int j=indofdot+1;j<tore.length();j++){ afterdot.append(String.valueOf(tore.charAt(j))); } }return beforedot.toString()+afterdot.toString(); }
public static double eval(final String str) {
return new Object() {int pos = -1, ch;void nextChar() {
ch = (++pos < str.length()) ? str.charAt(pos) : -1;
}boolean eat(int charToEat) {
while (ch == ' ') nextChar();
if (ch == charToEat) { nextChar();
return true;
}return false;
}double parse() {
nextChar();double x = parseExpression();
if (pos < str.length()) throw new RuntimeException("Unexpected: " + (char)ch);
return x;
}double parseExpression() { double x = parseTerm();
for (;;) { if (eat('+')) x += parseTerm();
else if (eat('-')) x -= parseTerm();else return x;
} }double parseTerm() { double x = parseFactor();
for (;;) { if (eat('x')) x *= parseFactor();
else if (eat('/')) x /= parseFactor();
else if (eat('%')) x %= parseFactor();else return x;
} }double parseFactor() {
if (eat('+')) return parseFactor();
if (eat('-')) return -parseFactor();
double x;
int startPos = this.pos;if (eat('(')) { x = parseExpression();
eat(')'); } else if ((ch >= '0' && ch <= '9') || ch == '.') {
while ((ch >= '0' && ch <= '9') || ch == '.') nextChar();
x = Double.parseDouble(str.substring(startPos, this.pos));
} else if (ch >= 'a' && ch <= 'z') { while (ch >= 'a' && ch <= 'z') nextChar();
String func = str.substring(startPos, this.pos);x = parseFactor();
if (func.equals("sqrt")) x = Math.sqrt(x);
else if (func.equals("sin")) x = Math.sin(Math.toRadians(x));
else if (func.equals("cos")) x = Math.cos(Math.toRadians(x));
else if (func.equals("tan")) x = Math.tan(Math.toRadians(x));
else throw new RuntimeException("Unknown function: " + func);
} else { throw new RuntimeException("Unexpected: " + (char)ch);
}if (eat('^')) x = Math.pow(x, parseFactor());return x;
}}.parse(); }
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,button11;
b3=(Button) findViewById(R.id.b3);
b4=(Button) findViewById(R.id.b4);
b6=(Button) findViewById(R.id.b6);
Button button5=(Button) findViewById(R.id.button5);
@SuppressLint("CutPasteId") Button button70=(Button) findViewById(R.id.button70);
Button button6=(Button) findViewById(R.id.button6);
Button button8=(Button) findViewById(R.id.button8);
Button bb =(Button) findViewById(R.id.b);
b7=(Button) findViewById(R.id.b7);
b8=(Button) findViewById(R.id.b8);
b9=(Button) findViewById(R.id.b9);
b10=(Button) findViewById(R.id.b10);
b11=(Button) findViewById(R.id.b11);
b12=(Button) findViewById(R.id.b12);
b13=(Button) findViewById(R.id.b13);
b14=(Button) findViewById(R.id.b14);
b15=(Button) findViewById(R.id.b15);
b16=(Button) findViewById(R.id.b16);
b17=(Button) findViewById(R.id.b17);
button11=(Button) findViewById(R.id.button11);
TextView textView2=(TextView)findViewById(R.id.textView2);
final TextView textView4=(TextView)findViewById(R.id.textView4);
Button dittoimage=(Button)findViewById(R.id.dittoimage);
final TextView textView=(TextView) findViewById(R.id.textView);
dittoimage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(MainActivity.this,login.class);
startActivity(intent); }
});
textView2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"H e y D i t t o H i e e e \nW h a t s u p . . .",Toast.LENGTH_SHORT).show();
}
});
button11.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { vv=remain+"1";
textView.setText(vv);remain=vv;
}
});
b4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){
vv=remain+"^";
}else{
vv=replacingtsymbol(vv,'^'); }
textView.setText(vv);
remain=vv;
}
});
b3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"7";
textView.setText(vv);
remain=vv;
}
});bb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"4";
textView.setText(vv);
remain=vv;
}
});
b6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"8";
textView.setText(vv);
remain=vv; }
});
b7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"5";
textView.setText(vv);
remain=vv;
}
});
b8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"2";
textView.setText(vv);
remain=vv;
}
});
button70.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){
vv=remain+"%"; }else{
vv=replacingtsymbol(remain,'%'); }
textView.setText(vv);
remain=vv;
}
});
b9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"0";
textView.setText(vv);
remain=vv;
}
});
b12.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"3";
textView.setText(vv);
remain=vv;
}
});
b11.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"6";
textView.setText(vv);
remain=vv;
}
}); b10.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv=remain+"9";
textView.setText(vv);
remain=vv;
}
});
b13.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){
vv=remain+"."; }else{
vv=replacingtsymbol(remain,'.'); }
textView.setText(vv);
remain=vv;
}
});b14.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){
vv=remain+"x"; }else{
vv=replacingtsymbol(remain,'x'); }
textView.setText(vv);
remain=vv;
}
});
b15.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){
vv=remain+"-";
}
else{
vv=replacingtsymbol(remain,'-'); }
textView.setText(vv);
remain=vv;
}
});
b16.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){
vv=remain+"+"; }
else{
vv=replacingtsymbol(remain,'+'); }
textView.setText(vv);
remain=vv;
}
});
b17.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isCorrect(remain)){
Toast.makeText(MainActivity.this,"Please enter operand ...",Toast.LENGTH_SHORT).show(); }
else{
String result = (String.valueOf(eval(remain)));
// textView.setText(result);
textView4.setText(result);
remain = result; }
}
});
button5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vv="";
textView.setText(vv);
textView4.setText(vv);
remain=vv;
}
});
button6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StringBuilder newstring= new StringBuilder();
if (!isCorrect(vv)){
for (int i=0;i<remain.length()-1;i++){
newstring.append(remain.charAt(i)); } }
textView.setText(newstring.toString());
remain= newstring.toString(); }
});
button8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isCorrect(vv)){ vv=remain+"/"; }
else{ vv=replacingtsymbol(remain,'/'); }
textView.setText(vv);
remain=vv;
}
});
}
}
## XML CODE ##
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00BCD4"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="405dp"
android:layout_height="67dp"
android:layout_marginTop="110dp"
android:alpha="0.5"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/linearLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView">
<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CDF44336"
android:text="@string/c"
android:textColor="#FFFFFF"
android:textSize="36sp"
tools:ignore="ButtonStyle" />
<Button
android:id="@+id/button6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CDF44336"
android:text="@string/gg"
android:textColor="#FFFFFF"
android:textSize="36sp"
tools:ignore="ButtonStyle" />
<Button
android:id="@+id/button70"
android:layout_width="447dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CDF44336"
android:text="@string/dfg"
android:textColor="#FFFFFF"
android:textSize="36sp"
tools:ignore="ButtonStyle" />
<Button
android:id="@+id/button8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CDF44336"
android:paddingEnd="12dp"
android:paddingRight="12dp"
android:text="@string/h"
android:textColor="#FFFFFF"
android:textSize="36sp"
tools:ignore="ButtonStyle,RtlSymmetry" />
</LinearLayout>
<TextView
android:id="@+id/textView"
android:layout_width="384dp"
android:layout_height="39dp"
android:layout_marginBottom="100dp"
android:background="#00CDDC39"
android:hint="@string/text_will_be_here"
android:textColor="#F3C94D4D"
android:textColorHint="#20FFFFFF"
android:textSize="36sp"
app:layout_constraintBottom_toTopOf="@+id/linearLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.482"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.491" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="405dp"
android:layout_height="403dp"
android:background="#9C27B0"
android:orientation="horizontal"
android:paddingBottom="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/b3"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_7"
android:textColor="#FAF7F7"
android:textSize="36sp" />
<Button
android:id="@+id/b"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_4"
android:textColor="#FAF7F7"
android:textSize="36sp" />
<Button
android:id="@+id/button11"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_1"
android:textColor="#FAF7F7"
android:textSize="36sp" />
<Button
android:id="@+id/b4"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/x_y"
android:textColor="#D3FAF7F7"
android:textSize="24sp"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="104dp"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/b6"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_8"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b7"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_5"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b8"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_2"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b9"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_0"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
</LinearLayout>
<LinearLayout
android:layout_width="102dp"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/b10"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_9"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b11"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_6"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b12"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/_3"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b13"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/fg"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
</LinearLayout>
<LinearLayout
android:layout_width="111dp"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/b14"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/x"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b15"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/dr"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b16"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/adg"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
<Button
android:id="@+id/b17"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#D67AE6"
android:text="@string/sdfg"
android:textColor="#FAFFFFFF"
android:textSize="36sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/textView2"
android:layout_width="301dp"
android:layout_height="26dp"
android:layout_marginTop="5dp"
android:text="@string/yui"
android:textSize="18sp"
app:fontFamily="cursive"
app:layout_constraintBottom_toTopOf="@+id/textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.118"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/textView4"
android:layout_width="387dp"
android:layout_height="66dp"
android:textColorHint="#432196F3"
android:textSize="56sp"
app:layout_constraintBottom_toTopOf="@+id/linearLayout2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/dittoimage"
android:layout_width="54dp"
android:layout_height="27dp"
android:layout_marginBottom="28dp"
android:background="#00BCD4"
android:clickable="true"

android:focusable="true"
android:scrollbarSize="0dp"
android:textSize="18sp"
app:layout_constraintBottom_toTopOf="@+id/textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>


Comments
Post a Comment