📄 caculator_未解决十进制以外的数值输入和计算问题.java
字号:
b_cos.setText("<html><font color=gray>cos</font></html>"); b_tan.setText("<html><font color=gray>tan</font></html>"); b_FE.setText("<html><font color=gray>F-E</font></html>"); b_dms.setText("<html><font color=gray>dms</font></html>"); b_Exp.setText("<html><font color=gray>Exp</font></html>"); b_pi.setText("<html><font color=gray>pi</font></html>"); b_jz = 16; } else if(e.getSource() == dec)//十进制按钮显示 { A.setEnabled(false); B.setEnabled(false); C.setEnabled(false); D.setEnabled(false); E.setEnabled(false); F.setEnabled(false); b_8.setEnabled(true); b_9.setEnabled(true); b_7.setEnabled(true); b_6.setEnabled(true); b_5.setEnabled(true); b_4.setEnabled(true); b_3.setEnabled(true); b_2.setEnabled(true); A.setText("<html><font color=gray>A</font></html>"); B.setText("<html><font color=gray>B</font></html>"); C.setText("<html><font color=gray>C</font></html>"); D.setText("<html><font color=gray>D</font></html>"); E.setText("<html><font color=gray>E</font></html>"); F.setText("<html><font color=gray>F</font></html>"); b_8.setText("<html><font color=blue>8</font></html>"); b_9.setText("<html><font color=blue>9</font></html>"); b_7.setText("<html><font color=blue>7</font></html>"); b_6.setText("<html><font color=blue>6</font></html>"); b_5.setText("<html><font color=blue>5</font></html>"); b_4.setText("<html><font color=blue>4</font></html>"); b_3.setText("<html><font color=blue>3</font></html>"); b_2.setText("<html><font color=blue>2</font></html>"); b_FE.setEnabled(true); b_dms.setEnabled(true); b_Exp.setEnabled(true); b_sin.setEnabled(true); b_cos.setEnabled(true); b_tan.setEnabled(true); b_pi.setEnabled(true); b_sin.setText("<html><font color=blue>sin</font></html>"); b_cos.setText("<html><font color=blue>cos</font></html>"); b_tan.setText("<html><font color=blue>tan</font></html>"); b_FE.setText("<html><font color=blue>F-E</font></html>"); b_dms.setText("<html><font color=blue>dms</font></html>"); b_Exp.setText("<html><font color=blue>Exp</font></html>"); b_pi.setText("<html><font color=blue>pi</font></html>"); b_jz = 10; } else if(e.getSource() == oct)//八进制按钮显示 { A.setEnabled(false); B.setEnabled(false); C.setEnabled(false); D.setEnabled(false); E.setEnabled(false); F.setEnabled(false); b_8.setEnabled(false); b_9.setEnabled(false); b_7.setEnabled(true); b_6.setEnabled(true); b_5.setEnabled(true); b_4.setEnabled(true); b_3.setEnabled(true); b_2.setEnabled(true); A.setText("<html><font color=gray>A</font></html>"); B.setText("<html><font color=gray>B</font></html>"); C.setText("<html><font color=gray>C</font></html>"); D.setText("<html><font color=gray>D</font></html>"); E.setText("<html><font color=gray>E</font></html>"); F.setText("<html><font color=gray>F</font></html>"); b_8.setText("<html><font color=gray>8</font></html>"); b_9.setText("<html><font color=gray>9</font></html>"); b_7.setText("<html><font color=blue>7</font></html>"); b_6.setText("<html><font color=blue>6</font></html>"); b_5.setText("<html><font color=blue>5</font></html>"); b_4.setText("<html><font color=blue>4</font></html>"); b_3.setText("<html><font color=blue>3</font></html>"); b_2.setText("<html><font color=blue>2</font></html>"); b_FE.setEnabled(false); b_dms.setEnabled(false); b_Exp.setEnabled(false); b_sin.setEnabled(false); b_cos.setEnabled(false); b_tan.setEnabled(false); b_pi.setEnabled(false); b_sin.setText("<html><font color=gray>sin</font></html>"); b_cos.setText("<html><font color=gray>cos</font></html>"); b_tan.setText("<html><font color=gray>tan</font></html>"); b_FE.setText("<html><font color=gray>F-E</font></html>"); b_dms.setText("<html><font color=gray>dms</font></html>"); b_Exp.setText("<html><font color=gray>Exp</font></html>"); b_pi.setText("<html><font color=gray>pi</font></html>"); b_jz = 8; } else if(e.getSource() == b)//二进制按钮显示 { A.setEnabled(false); B.setEnabled(false); C.setEnabled(false); D.setEnabled(false); E.setEnabled(false); F.setEnabled(false); b_8.setEnabled(false); b_9.setEnabled(false); b_7.setEnabled(false); b_6.setEnabled(false); b_5.setEnabled(false); b_4.setEnabled(false); b_3.setEnabled(false); b_2.setEnabled(false); A.setText("<html><font color=gray>A</font></html>"); B.setText("<html><font color=gray>B</font></html>"); C.setText("<html><font color=gray>C</font></html>"); D.setText("<html><font color=gray>D</font></html>"); E.setText("<html><font color=gray>E</font></html>"); F.setText("<html><font color=gray>F</font></html>"); b_8.setText("<html><font color=gray>8</font></html>"); b_9.setText("<html><font color=gray>9</font></html>"); b_7.setText("<html><font color=gray>7</font></html>"); b_6.setText("<html><font color=gray>6</font></html>"); b_5.setText("<html><font color=gray>5</font></html>"); b_4.setText("<html><font color=gray>4</font></html>"); b_3.setText("<html><font color=gray>3</font></html>"); b_2.setText("<html><font color=gray>2</font></html>"); b_FE.setEnabled(false); b_dms.setEnabled(false); b_Exp.setEnabled(false); b_sin.setEnabled(false); b_cos.setEnabled(false); b_tan.setEnabled(false); b_pi.setEnabled(false); b_sin.setText("<html><font color=gray>sin</font></html>"); b_cos.setText("<html><font color=gray>cos</font></html>"); b_tan.setText("<html><font color=gray>tan</font></html>"); b_FE.setText("<html><font color=gray>F-E</font></html>"); b_dms.setText("<html><font color=gray>dms</font></html>"); b_Exp.setText("<html><font color=gray>Exp</font></html>"); b_pi.setText("<html><font color=gray>pi</font></html>"); b_jz = 2; } if(e.getSource() == item0)//退出 { System.exit(0); } if(e.getSource() == item1)//复制 { t_show.setEditable(true); t_show.selectAll(); t_show.copy(); t_show.setEditable(false); } else if(e.getSource() == item2)//粘贴 { t_show.setEditable(true); t_show.selectAll(); t_show.paste(); validate(); t_show.setEditable(false); } else if(e.getSource() == item5)//帮助 { String s = "标准型:\r\nBackspace — 逐个删除\r\nsqrt — 开平方\r\nC — 全部清除\r\nCE — 一次运算完成后,单击“CE”按钮即可清除当前的运算结果,再次输入时可开始新的运算\r\nMC — 是清除储存数据\r\nMR — 是读取储存的数据\r\nMS — 将所显示的数存入存储器中,存储器中原有的数据被冲走,“—”也会变为“M”\r\nM+ — 是计算结果并加上已经储存的数\r\n1/x — 求倒数\r\n+/- — 改变当前数的符号\r\n% — 计算a*(b%),如输入a-b%=a-a*(b%);例:50+25%它会先计算出50*(25%)=12.5,然后按等号后,显示62.5(即50+12.5)\r\n科学型:\r\nsin — 计算三角函数sin值(默认角度制)\r\ncos — 计算三角函数cos值(默认角度制)\r\ntan — 计算三角函数tan值(默认角度制)\r\nn! — 计算n的阶乘(只限于100以内的数)\r\nlog — 计算以10为底的对数\r\nln — 计算自然对数\r\nx^y — 计算x的y次方\r\n 计算器的运算结果可以导入到别的应用程序中,用户可以选择“编辑”—“复制”把运算结果粘贴到别处,也可以从别的地方复制好运算算式后,选择“编辑”—“粘贴”到计算器中进行运算。"; Dialog d = new Dialog(this,"帮助主题",s,550,520); } else if(e.getSource() == item6)//关于 { String s = "版权所有 (c) 2008\r\n制作者:李育胤 班级:05嵌入式软件与系统 学号:05384025"; Dialog d = new Dialog(this,"关于软件",s,360,100); } //操作指令事件############################################## else if(e.getSource() == b_Backspace) { if (t_show.getText().length() <= 1) { t[state] = "0"; start = 0;//说明重新输入,清空以前数据 } else { t[state] = t_show.getText().substring(0, t_show.getText().length()-1); } d[state] = Double.parseDouble(t[state]); t_show.setText(t[state]); } else if(e.getSource() == b_C)//删掉所有状态与数值 { for (int i=0;i<11;i++) { t[i]="0"; d[i]=0; if (i<5) marks[i]=0; } state=1; start=0; mark=1; t_show.setText("0"); k1=k2=0; t_K.setText(" — "); } else if(e.getSource() == b_CE)//删除当前状态与数值 { clear(); t_show.setText("0"); } //储存器操作按钮事件######################################## else if(e.getSource() == b_MC) { Mdate=0; t_M.setText(" — "); validate(); } else if(e.getSource() == b_MR) { d[state]=Mdate; t[state]=String.valueOf(Mdate); t_show.setText(String.valueOf(Mdate)); } else if(e.getSource() == b_MS) { start=0;//说明重新输入,清空以前数据 Mdate=Double.parseDouble(t_show.getText()); t_M.setText(" M "); validate(); } else if(e.getSource() == b_Madd) { Mdate+=Double.parseDouble(t_show.getText()); t_M.setText(" M "); validate(); } //数字按钮事件########################################### else if(e.getSource() == b_0) { input("0"); } else if(e.getSource() == b_1) { input("1"); } else if(e.getSource() == b_2) { input("2"); } else if(e.getSource() == b_3) { input("3"); } else if(e.getSource() == b_4) { input("4"); } else if(e.getSource() == b_5) { input("5"); } else if(e.getSource() == b_6) { input("6"); } else if(e.getSource() == b_7) { input("7"); } else if(e.getSource() == b_8) { input("8"); } else if(e.getSource() == b_9) { input("9"); } else if(e.getSource() == b_dian) { input("."); } if(b_jz == 16) { if(e.getSource() == A) { input("A"); } else if(e.getSource() == B) { input("B"); } else if(e.getSource() == C) { input("C"); } else if(e.getSource() == D) { input("D"); } else if(e.getSource() == E) { input("E"); } else if(e.getSource() == F) { input("F"); } } //四则运算操作事件########################################
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -