java小项目之简易计算器,适合正在学习java的同学练练手,理解一些关于java的重要的设计理念和相关知识哦。西西
功能描述
- 数字按键提供10个数字按键(0,1,2,3,4,5,6,7,8,9),鼠标直接点击按钮输入数字,并在当前数据文本框显示。
- 四则运算符提供加法、减法、乘法、除法四则运算,当用户用鼠标点击数字按钮输入第一个操作数,按用户需求点击加减乘除运算符的其中一个按钮,然后输入第二个操作数,点击等号即可得出计算结果。
- 等号按键用户鼠标点击等号按键,在文本显示区显示当前的计算结果。
- 其他运算本计算器提供其他运算符,包括sin(正弦函数)、sqrt(开平方)、1/x(求倒数)、+/-(求相反数)等常用函数的计算功能,使用时,先输入数字,再单击函数按钮,即可直接得出计算结果。
- 数据清除按钮提供清零功能,可以清除当前结果显示区域输入的所有数字。提供退格功能,可以清除当前输入数字的最后一位,且支持连续退格。
1.SimpleCalculator.java
该文件包含一个public SimpleCalcuGlator类,该类继承JFrame,是系统运行的主类,负责创建计算器的主窗口。main()方法用于系统启动,是程序的入口。LinkedList<String>是String类型的操作数链表,用于保存两个操作数和一个运算符,用于计算。NumberBtn[]数组是数字按钮0~9,OperatorBtn[]数组是操作符按钮“+”、“-”、“∗”、“/”,SimpleCalcuGlator()是构造方法,用于设计计算器的图形主界面,并且包含相关按钮的监听事件。
package SimpleCalculator;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.border.SoftBevelBorder;
import java.awt.*;
import java.util.LinkedList;
//完成系统的启动
public class SimpleCalculator extends JFrame {
private NumberBtn numberBtn[];
private OperatorBtn operatorBtn[];
private JButton point,sign,backspace,equals,zero,sin,sqrt,reci;
private JTextField textResult;
private LinkedList<String> numList;
private NumberListener numberListener;
private OperationListener operationListener;
private BackspaceListener backspaceListener;
private ClearListener clearListener;
private EqualListener equalListener;
private PointListener pointListener;
private ReveresListener reveresListener;
private SinListener sinListener;
private SqrtListener sqrtListener;
private ReciprocalListener reciprocalListener;
public SimpleCalculator(){
this.setTitle("简易计算器");
this.numList=new LinkedList<String>();
//结果显示区
this.textResult=new JTextField(10);
this.textResult.setHorizontalAlignment(JTextField.RIGHT);
this.textResult.setForeground(Color.BLUE);
this.textResult.setFont(new Font("TimesRoman",Font.BOLD,20));
this.textResult.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
this.textResult.setEditable(false);
this.textResult.setBackground(Color.WHITE);
//数字按钮
this.numberBtn=new NumberBtn[10];
this.numberListener=new NumberListener(this.numList,this.textResult);
for (int i=0;i<=9;i++){
this.numberBtn[i]=new NumberBtn(i);
this.numberBtn[i].setFont(new Font("Arial", Font.BOLD,18));
this.numberBtn[i].addActionListener(this.numberListener);
}
//操作按钮
this.operatorBtn=new OperatorBtn[4];
this.operationListener=new OperationListener(this.numList,this.textResult);
String[] calculator={"+","-","*","/"};
for(int i=0;i<4;i++){
this.operatorBtn[i]=new OperatorBtn(calculator[i]);
this.operatorBtn[i].setFont(new Font("Arial",Font.BOLD,18));
this.operatorBtn[i].addActionListener(this.operationListener);
}
//小数点.=等其他按钮
this.sin=new JButton("sin");
this.sinListener=new SinListener(this.numList,this.textResult);
this.sin.addActionListener(this.sinListener);
this.sqrt=new JButton("sqrt");
this.sqrtListener=new SqrtListener(this.numList,this.textResult);
this.sqrt.addActionListener(this.sqrtListener);
this.sign=new JButton("+/-");
this.reveresListener=new ReveresListener(this.numList,this.textResult);
this.sign.addActionListener(this.reveresListener);
this.equals=new JButton("=");
this.equalListener=new EqualListener(this.numList,this.textResult);
this.equals.addActionListener(this.equalListener);
this.point=new JButton(".");
this.pointListener=new PointListener(this.numList,this.textResult);
this.point.addActionListener(this.pointListener);
this.reci=new JButton("1/x");
this.reciprocalListener=new ReciprocalListener(this.numList,this.textResult);
this.reci.addActionListener(this.reciprocalListener);
//退格i,清除等号键的运用
this.backspace=new JButton("退格");
this.backspaceListener=new BackspaceListener(this.numList,this.textResult);
this.backspace.addActionListener(this.backspaceListener);
this.backspace.setFont(new Font("微软雅黑",Font.BOLD,16));
this.zero=new JButton("清零");
this.clearListener=new ClearListener(this.numList,this.textResult);
this.zero.addActionListener(this.clearListener);
this.zero.setFont(new Font("微软雅黑",Font.BOLD,16));
this.zero.setForeground(Color.GREEN);
this.backspace.setForeground(Color.GREEN);
this.equals.setForeground(Color.RED);
this.sin.setForeground(Color.BLUE);
this.sign.setForeground(Color.BLUE);
this.point.setForeground(Color.BLUE);
this.sqrt.setForeground(Color.BLUE);
this.reci.setForeground(Color.BLUE);
//窗口的设计分为两部分
JPanel panelDown,panelUp;
panelUp=new JPanel(new BorderLayout());
panelUp.add(this.textResult,BorderLayout.CENTER);
//数字存放区计算窗口按钮的摆放
panelDown=new JPanel();
panelDown.setLayout(new BorderLayout());
JPanel NorthInRight=new JPanel();
JPanel centerInRight=new JPanel();
JPanel SouthInRight=new JPanel();
panelDown.add(NorthInRight, BorderLayout.CENTER);
NorthInRight.setLayout(new GridLayout(1,2,30,30));
NorthInRight.add(zero);
NorthInRight.add(backspace);
//分割线
JSplitPane split1=new JSplitPane(JSplitPane.VERTICAL_SPLIT,NorthInRight,centerInRight);
panelDown.add(split1,BorderLayout.NORTH);
panelDown.add(centerInRight,BorderLayout.WEST);
centerInRight.setLayout(new GridLayout(4,3,10,8));
centerInRight.add(numberBtn[7]);
centerInRight.add(numberBtn[8]);
centerInRight.add(numberBtn[9]);
centerInRight.add(numberBtn[4]);
centerInRight.add(numberBtn[5]);
centerInRight.add(numberBtn[6]);
centerInRight.add(numberBtn[1]);
centerInRight.add(numberBtn[2]);
centerInRight.add(numberBtn[3]);
centerInRight.add(numberBtn[0]);
centerInRight.add(point);
centerInRight.add(reci);
//分割线
JSplitPane split2=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,centerInRight,SouthInRight);
panelDown.add(split2,BorderLayout.CENTER);
panelDown.add(SouthInRight,BorderLayout.EAST);
SouthInRight.setLayout(new GridLayout(4,2,10,8));
SouthInRight.add(operatorBtn[0]);
SouthInRight.add(sin);
SouthInRight.add(operatorBtn[1]);
SouthInRight.add(sqrt);
SouthInRight.add(operatorBtn[2]);
SouthInRight.add(sign);
SouthInRight.add(operatorBtn[3]);
SouthInRight.add(equals);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JSplitPane split=new JSplitPane(JSplitPane.VERTICAL_SPLIT,panelUp,panelDown);
add(split,BorderLayout.CENTER);
setVisible(true);
setBounds(500,350,450,280);
validate();
}
//计算机程序运行的入口函数
public static void main(String[] args) {
new SimpleCalculator();
}
}
2.NumberBtn.java
该文件包含一个public NumberBtn类,该类继承JButton,主要功能是设置主窗口中(0~9)10个数字按钮样式,该类中有一个int类型的成员number,用来表示按钮表示的数字,该类包含两个方法,构造方法NumberBtn()设计数字按钮的字体,大小,以及数字的颜色。方法getNumber()返回其所含有的数字。
package SimpleCalculator;
import javax.swing.*;
import java.awt.*;
//完成数字按钮的初始化设计
public class NumberBtn extends JButton {
private int number;
public NumberBtn(int number){
this.number=number;
this.setText(""+number);
this.setBackground(Color.BLUE);
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
}
3.OperatorBtn.java
该文件包含一个public OperatorBtn类,该类继承JButton,主要功能是创建的对象主窗口中的“+”,“-”,“∗”,“/”四个运算符按钮,该类有一个String类型的成员OperateStr,用于标明创建的按钮所包含的运算符,该类包含两个方法,构造方法用于创建四个按钮的文本以及颜色设置.。方法getOpStr()返回其所含有的运算符。
package SimpleCalculator;
import javax.swing.*;
import java.awt.*;
//完成操作按钮的初始化设计
public class OperatorBtn extends JButton {
private String operateStr;
public OperatorBtn(String str){
this.operateStr=str;
this.setText(str);
this.setBackground(Color.RED);
}
public String getOperateStr() {
return operateStr;
}
public void setOperateStr(String operateStr) {
this.operateStr = operateStr;
}
}
4.BaseListener.java
该文件包含一个public abstractBaseListener类,实现了ActionListener接口,是一个抽象类,所以不能创建对象,只能够被继承,封装了其他监听器类的通用属性,所有的监听器类都继承该类,同时重写事件处理方法actionPerformed()。
package SimpleCalculator;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.util.LinkedList;
//封装监听器类的通用属性
//按钮监听事件的父类
public abstract class BaseListerner implements ActionListener {
protected LinkedList<String> list;
protected JTextField resultShow;
public BaseListerner(){};
public BaseListerner(LinkedList<String> list,JTextField resultShow){
super();
this.list=list;
this.resultShow=resultShow;
}
}
5 .OpUtil.java
该文件包含一个public OpUtil类,该类提供一个getResult()方法,主要功能是解析LinkedList链表中的两个操作数和运算符,并根据获得的加减乘除运算符进行计算,并返回结果。
package SimpleCalculator;
//封装四则运算的业务逻辑
public class OpUtil {
public static double getResult(String op,double n1,double n2){
double result=0;
switch (op) {
case "+":
result = n1 + n2;
break;
case "-":
result = n1 - n2;
break;
case "*":
result = n1 * n2;
break;
case "/":
result = n1 / n2;
break;
}
return result;
}
}
6.NumberListener.java
该文件包含一个public NumberListener类,该类继承了父类Baselistener,并实现了ActionListener中的actionPerformed()方法。创建的对象负责操作按钮处理ActionEvent事件,实现了actionPerformed()方法。该类主要处理数字按钮,将操作数放入链表对应位置,单击0~9十个数字按钮时,actionPerformed()方法将被调用执行。
package SimpleCalculator;
import SimpleCalculator.BaseListerner;
import SimpleCalculator.NumberBtn;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.LinkedList;
//完成数字按键(0123456789)的事件监听处理
public class NumberListener extends BaseListerner {
public NumberListener(LinkedList<String> list, JTextField resultShow){
super(list,resultShow);
}
public void actionPerformed(ActionEvent e){
NumberBtn b=(NumberBtn) e.getSource();
switch (list.size()){
case 0:
case 2: {
int number = b.getNumber();
list.add(""+number);
resultShow.setText(""+number);
}break;
case 1:{
int number=b.getNumber();
String num= list.getFirst();
String s=num.concat(""+number);
list.set(0,s);
resultShow.setText(s);
}break;
case 3:{
int number=b.getNumber();
String num=list.getLast();
String s=num.concat(""+number);
list.set(2,s);
resultShow.setText(s);
}break;
default:
break;
}
}
}
7.OperatorListener.java
该文件包含一个public OperatorListener类,该类继承了父类Baselistener,并实现了ActionListener中的actionPerformed()方法。创建的对象负责操作按钮处理ActionEvent事件,实现了actionPerformed()方法。该类主要处理加减乘除四则运算,将操作数和运算符放入链表对应位置,单击运算符操作按钮,actionPerformed()方法将被调用执行所示。
package SimpleCalculator;
import SimpleCalculator.BaseListerner;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.LinkedList;
//完成操作按键的事件监听处理
//运算符(加减乘除)的事件监听
public class OperationListener extends BaseListerner {
public OperationListener(LinkedList<String> list, JTextField resultShow){
super(list,resultShow);
}
public void actionPerformed(ActionEvent e){
OperatorBtn b=(OperatorBtn) e.getSource();
switch (list.size()){
case 1:{
String op=b.getOperateStr();
list.add(op);
}break;
case 2:{
String op=b.getOperateStr();
list.add(1,op);
}break;
case 3:{
String numOne=list.getFirst();
String numTwo=list.getLast();
String op=list.get(1);
try{
double n1=Double.parseDouble(numOne);
double n2=Double.parseDouble(numTwo);
double result=0;
result= OpUtil.getResult(op,n1,n2);
String oper=b.getOperateStr();
list.clear();
list.add(""+result);
list.add(oper);
resultShow.setText(""+result);
}catch (Exception e1){
throw new RuntimeException(e1);
}
}break;
default:
break;
}
}
}
8.EqualListener.java
该文件包含一个publicEqualListener类,该类继承了父类Baselistener,该类创建的对象负责处理ActionEvent事件,实现了actionPerformed()方法,创建的对象EqualListener是SimpleCalculator窗口的组成成员之一。该类主要处理等号事件,通过调用OpUtil的getResult方法进行计算,得出结果。当用户单事件actionPerformed()方法将被调用执行。
package SimpleCalculator;
import SimpleCalculator.BaseListerner;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.LinkedList;
//完成“等号”按键的事件监听处理
public class EqualListener extends BaseListerner {
public EqualListener(LinkedList<String> list, JTextField resultShow){
super(list,resultShow);
}
@Override
public void actionPerformed(ActionEvent e) {
switch (list.size()){
case 1:{
String num=list.getFirst();
resultShow.setText(""+num);
}break;
case 2:{
String num=list.getFirst();
String op=list.get(1);
try {
double n1= Double.parseDouble(num);
double n2= Double.parseDouble(num);
double result=0;
result= OpUtil.getResult(op,n1,n2);
resultShow.setText(""+result);
list.add(0,""+result);
}catch (Exception e1){
throw new RuntimeException(e1);
}
}break;
case 3:{
String numOne=list.getFirst();
String numTwo=list.getLast();
String op=list.get(1);
try {
double n1= Double.parseDouble(numOne);
double n2= Double.parseDouble(numTwo);
double result=0;
result= OpUtil.getResult(op,n1,n2);
resultShow.setText(""+result);
list.add(0,""+result);
list.removeLast();
list.removeLast();
}catch (Exception e2){
throw new RuntimeException(e2);
}
}break;
default:
break;
}
}
}
9.ClearListener.java
该文件包含一个public ClearListener类,该类继承了父类Baselistener,该类创建的对象负责处理ActionEvent事件,实现了actionPerformed()接口,创建的对象ClearListener是SimpleCalculator窗口的组成成员之一。该类包含一个成员变量list,这是一个LinkedList<String>链表,用来存放两个操作数和一个运算符。当用户单击“清零”操作按钮时,就会触发ActionEvent事件,actionPerformed()方法将被调用执行,其操作就是清除链表中存储的运算数和操作符,并且设置txtResult中显示的数字为0。
package SimpleCalculator;
import SimpleCalculator.BaseListerner;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.LinkedList;
//完成”清空“按键的事件监听处理
public class ClearListener extends BaseListerner {
public ClearListener(LinkedList<String> list, JTextField resultShow){
super(list,resultShow);
}
@Override
public void actionPerformed(ActionEvent e) {
this.resultShow.setText("0");
this.list.clear();
}
}
10.BackspaceListener.java
该文件包含一个public ClearListener类,该类继承了父类Baselistener,创建的对象负责处理ActionEvent事件,实现了actionPerformed()方法,创建的对象BackspaceListener是SimpleCalculator窗口的组成成员之一。该类包含一个成员变量list,这是一个LinkedList<String>链表,用来存放两个操作数和一个运算符。当用户单击“退格”操作按钮时,就会触发ActionEvent事件,actionPerformed()方法将被调用执行,其操作就是清除链表中存储的运算数最后一位。
package SimpleCalculator;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.LinkedList;
//完成”退格“按键的事件监听处理
public class BackspaceListener extends BaseListerner {
public BackspaceListener(LinkedList<String> numlist, JTextField txtResult){
super(numlist,txtResult);
}
@Override
public void actionPerformed(ActionEvent e) {
switch (list.size()){
case 1:{
String num=(String) this.list.getFirst();
if(!num.isEmpty()){
num=num.substring(0,num.length()-1);
this.list.set(0,num);
resultShow.setText(num);
}else {
this.list.removeLast();
resultShow.setText("0");
}
}break;
case 3:{
String num=(String) this.list.getFirst();
if(!num.isEmpty()){
num=num.substring(0,num.length()-1);
this.list.set(2,num);
resultShow.setText(num);
}else {
this.list.removeLast();
resultShow.setText("0");
}
}break;
default:
break;
}
}
}
11.PointListener.java
该文件包含一个public PointListener类,该类继承了父类Baselistener,该类创建的对象负责处理ActionEvent事件,实现了actionPerformed()方法,创建的对象PointListener是SimpleCalculator窗口的组成成员之一。该类主要处理小数点,将小数点前后两部分合成一个字符串.当用户单击“.”操作按钮时,就会触发ActionEvent事件,actionPerformed()方法将被调用执行。
package SimpleCalculator;
import SimpleCalculator.BaseListerner;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.LinkedList;
public class PointListener extends BaseListerner {
public PointListener(LinkedList<String> list, JTextField resultShow){
super(list,resultShow);
}
@Override
public void actionPerformed(ActionEvent e) {
String point=e.getActionCommand();
switch (list.size()){
case 1:{
String num=list.getFirst();
String s=null;
if(!num.contains(point)){
s=num.concat(point);
list.set(0,s);
}else {
s=num;
}list.set(0,s);
resultShow.setText(s);
}break;
case 2:{
String num=list.getLast();
String s=null;
if(!num.contains(point)){
s=num.concat(point);
list.set(2,s);
}else {
s=num;
}resultShow.setText(s);
}break;
default:
break;
}
}
}
12.SinListener.java
该文件包含一个public SinListener类,该类继承了父类Baselistener,创建的对象负责处理ActionEvent事件,实现了actionPerformed()方法,创建的对象BackspaceListener是SimpleCalculator窗口的组成成员之一。当用户单击“sin”操作按钮时,就会触发ActionEvent事件,actionPerformed()方法将被调用执行,其操作就是求当前操作数正弦值。
package SimpleCalculator;
import SimpleCalculator.BaseListerner;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.LinkedList;
public class SinListener extends BaseListerner {
public SinListener(LinkedList<String> list, JTextField resultShow){
super(list,resultShow);
}
@Override
public void actionPerformed(ActionEvent e) {
switch (list.size()){
case 1:
case 2:{
String numOne=list.getFirst();
try {
double x=Double.parseDouble(numOne);
double result =Math.sin(x);
String str=String.valueOf(result);
list.set(0,str);
resultShow.setText(str);
if(list.size()==2) list.removeLast();
}catch (Exception e1){
throw new RuntimeException(e1);
}
}break;
case 3:{
String numTwo=list.getLast();
try {
double x=Double.parseDouble(numTwo);
double result =Math.sin(x);
String str=String.valueOf(result);
list.set(0,str);
resultShow.setText(str);
list.removeLast();
list.removeLast();
}catch (Exception e1){
throw new RuntimeException(e1);
}
}break;
default:
break;
}
}
}
13.SqrtListener.java
该文件包含一个public SinListener类,该类继承了父类Baselistener,创建的对象负责处理ActionEvent事件,实现了actionPerformed()方法,创建的对象BackspaceListener是SimpleCalculator窗口的组成成员之一。该类包含一个成员变量list,这是一个LinkedList<string>链表,用来存放两个操作数和一个运算符。当用户单击“sqrt”操作按钮时,就会触发ActionEvent事件,actionPerformed()方法将被调用执行,其操作就是求当前操作数的平方根。
package SimpleCalculator;
import SimpleCalculator.BaseListerner;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.LinkedList;
//完成"开平方"按键的事件监听处理
public class SqrtListener extends BaseListerner {
public SqrtListener(LinkedList<String> list, JTextField resultShow){
super(list,resultShow);
}
@Override
public void actionPerformed(ActionEvent e) {
switch (list.size()){
case 1:
case 2:{
String numOne=list.getFirst();
try {
double d=Double.parseDouble(numOne);
double result =Math.sqrt(d);
String str=String.valueOf(result);
list.set(0,str);
resultShow.setText(str);
if(list.size()==2) list.removeLast();
}catch (Exception e1){
throw new RuntimeException(e1);
}
}break;
case 3:{
String numTwo=list.getLast();
try {
double d=Double.parseDouble(numTwo);
double result =Math.sqrt(d);
String str=String.valueOf(result);
list.set(0,str);
resultShow.setText(str);
list.removeLast();
list.removeLast();
}catch (Exception e1){
throw new RuntimeException(e1);
}
}break;
default:
break;
}
}
}
14.ReverseListener.java
该文件包含一个public ReverseListener类,该类继承了父类Baselistener,该类创建的对象负责处理ActionEvent事件,实现了actionPerformed()方法,创建的对象ReverseListener是SimpleCalculator窗口的组成成员之一。当用户单击“+/-”操作按钮时,就会触发ActionEvent事件,actionPerformed()方法将被调用执行,其操作就是将当前操作数乘以-1,取得相反数。
package SimpleCalculator;
import SimpleCalculator.BaseListerner;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.LinkedList;
//完成求相反数按键的事件监听处理
public class ReveresListener extends BaseListerner {
public ReveresListener(LinkedList<String> list, JTextField resultShow){
super(list,resultShow);
}
@Override
public void actionPerformed(ActionEvent e) {
switch (list.size()){
case 1:{
String number1=list.getFirst();
try {
double d=Double.parseDouble(number1);
d=-1*d;
String str=String.valueOf(d);
list.set(0,str);
resultShow.setText(str);
}catch (Exception e1){
throw new RuntimeException(e1);
}
}break;
case 3:{
String number2=list.getLast();
try {
double d=Double.parseDouble(number2);
d=-1*d;
String str=String.valueOf(d);
list.set(2,str);
resultShow.setText(str);
}catch (Exception e1){
throw new RuntimeException(e1);
}
}break;
default:
break;
}
}
}
15.ReciprocalListener.java
该文件包含一个public ReciprocalListener类,该类继承了父类Baselistener,创建的对象负责处理ActionEvent事件,实现了actionPerformed()方法,创建的对象ReciprocalListener是SimpleCalculator窗口的组成成员之一。当用户单击“1/x”操作按钮时,就会触发ActionEvent事件,actionPerformed()方法将被调用执行,其操作就是1除以当前操作数的倒数。
package SimpleCalculator;
import SimpleCalculator.BaseListerner;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.LinkedList;
//完成求倒数按键的事件监听处理
public class ReciprocalListener extends BaseListerner {
public ReciprocalListener(LinkedList<String> list, JTextField resultShow){
super(list,resultShow);
}
@Override
public void actionPerformed(ActionEvent e) {
switch (this.list.size()){
case 1:
case 2:{
String numOne= list.getFirst();
try {
double d=Double.parseDouble(numOne);
double result=1.0/d;
String str=String.valueOf(result);
list.set(0,str);
resultShow.setText(str);
if(list.size()==2) list.removeLast();
}catch (Exception e1){
throw new RuntimeException(e1);
}
}break;
case 3:{
String numTwo= list.getLast();
try {
double d=Double.parseDouble(numTwo);
double result=1.0/d;
String str=String.valueOf(result);
list.set(0,str);
resultShow.setText(str);
list.removeLast();
list.removeLast();
}catch (Exception e1){
throw new RuntimeException(e1);
}
}break;
default:
break;
}
}
}