2023年12月21日发(作者:特斯拉撞2车致2死)

android:layout_weight=\"1\" android:text=\"C\" android:textSize=\"30dip\" />

android:text=\"4\" android:textSize=\"30dip\" />

android:text=\"+\" android:textSize=\"30dip\" /> 逻辑部分package atorphonedemo;import patActivity;import patButton;import patTextView;import ;import ils;import ;import imal;import r;import ;import r;import n;public class MainActivity extends AppCompatActivity implements kListener { private AppCompatButton btnClear; private AppCompatButton btnAdd; private AppCompatButton btnSub; private AppCompatButton btnMultiply; private AppCompatButton btnDivide;

lickListener(this); lickListener(this); lickListener(this); t(\"0\"); } @Override public void onClick(View view) { switch (()) { case _add: setInputSymbol(\"+\"); break; case _sub: setInputSymbol(\"-\"); break; case _multiply: setInputSymbol(\"*\"); break; case _divide: setInputSymbol(\"/\"); break; case _zero: setInputNum(\"0\"); break; case _one: setInputNum(\"1\"); break; case _two: setInputNum(\"2\"); break; case _three: setInputNum(\"3\"); break; case _four: setInputNum(\"4\"); break; case _five: setInputNum(\"5\"); break; case _six: setInputNum(\"6\"); break; case _seven: setInputNum(\"7\"); break; case _eight: setInputNum(\"8\"); break; case _nine: setInputNum(\"9\"); break; case _point: boolean isSetPoint = false; for (int i = () - 1; i >= 0; i--) { char c = (i); if (!t(c)) { if (c != \'.\') { isSetPoint = true; break; } else { isSetPoint = false; break; }

} } if (i == 0) { isSetPoint = true; } } if (isSetPoint) { setInputSymbol(\".\"); } break; case _result: getResult(); break; case _backspace: if (() > 1) { operation = ing(0, () - 1); t(operation); } else { operation = \"0\"; t(\"0\"); } break; case _clear: operation = \"0\"; t(\"0\"); break; } } /** * 计算结果 */ private void getResult() { boolean isError = false; //计算错误标识 //判断等式结尾是否是字符,即未完成的等式 if (!y(operation)) { if (!isNumFinaly(operation)) { return; } } operation += \"#\"; if ((0) == \'-\') { operation = \"0\" + operation; } OPTR = new (); OPND = new (); (\"#\"); String buf = \"\"; String theta, a, b; char buffer; int i = 1; while ((i - 1) != \'#\' || () != \"#\") { if (buf != \"\") { (buf); } buffer = (()).charAt(0); if (Precede(buffer, (i - 1)) == \'>\') { theta = (); b = (); a = (); String operate = Operate(a, theta, b); if ((i - 1) == \'+\' || (i - 1) == \'-\' || (i - 1) == \'*\' || (i - 1) == \'/\' || (i - 1) == \'#\') {

} } } private boolean isNumFinaly(String str) { String lastStr = ing(() - 1, ()); Pattern pattern = e(\"[0-9]*\"); Matcher isNum = r(lastStr); if (s()) { return true; } else { return false; } } private String Operate(String a, String theta, String b) { char cao = (0); BigDecimal fa = new BigDecimal(a); BigDecimal fb = new BigDecimal(b); if (cao == \'+\') { return f((fb).stripTrailingZeros().toPlainString()); } else if (cao == \'-\') { return f(ct(fb).stripTrailingZeros().toPlainString()); } else if (cao == \'*\') { return f(ly(fb).stripTrailingZeros().toPlainString()); } else { if (eTo()==0) { return null; } else { return f((fb, 10, _HALF_UP).stripTrailingZeros().toPlainString()); } } } private char Precede(char peek, char c) { if (peek == \'+\' || peek == \'-\') { if (c == \'+\' || c == \'-\' || c == \'#\') return \'>\'; } if (peek == \'*\' || peek == \'/\') { return \'>\'; } if (c == \'#\') { return \'>\'; } else return \'<\'; }}

更多推荐

等式,字符,计算器,计算,部分,计算错误