麻烦哪位JAVA编程高手帮我看看,这个计算器中的X的Y次方怎么做? 怎么把科学和标准型分开 ,选择

* 将角度值转换成弧度值,方便三角函数的计算 */ else if(str.equals("′″")){ double i = Double.parseDouble(tf.getText()); tf.setText(String.valueOf(i/180*Math.PI)); } else{ if(flag){ IfResult = false; } if(IfResult){ oper = str; }else{ getResult(Double.parseDouble(tf.getText())); oper = str; IfResult = true; } } } } /** * 清除按钮的事件监听 */ class Clear implements ActionListener{ public void actionPerformed(ActionEvent e) { /* * 用ActionEvent对象的getActionCommand()方法 * 取得与引发事件对象相关的字符串 */ String str = e.getActionCommand(); if(str == "C"){ tf.setText("0"); IfResult = true; result = 0; }else if(str == "-/+"){ double i = 0 - Double.parseDouble(tf.getText().trim()); tf.setText(df.format(i)); }else if(str == "Backspace"){ if(Double.parseDouble(tf.getText()) > 0){ if(tf.getText().length() > 1){ tf.setText(tf.getText().substring(0, tf.getText().length() - 1)); //使用退格删除最后一位字符 }else{ tf.setText("0"); IfResult = true; } }else{ if(tf.getText().length() > 2){ tf.setText(tf.getText().substring(0, tf.getText().length() - 1)); }else{ tf.setText("0"); IfResult = true; } } }else if(str == "CE"){ tf.setText("0"); IfResult = true; } } } /** * 数字输入的事件监听 */ class Num implements ActionListener{ public void actionPerformed(ActionEvent e) { String str = e.getActionCommand(); if(IfResult){ tf.setText(""); IfResult = false; } if(str=="π") { tf.setText(String.valueOf(Math.PI)); } else if(str=="e") { tf.setText(String.valueOf(Math.E)); } else{ tf.setText(tf.getText().trim() + str); if(tf.getText().equals("0")){ tf.setText("0"); IfResult = true; flag = true; } } } } /** * 小数点的事件监听 */ class Dot implements ActionListener{ public void actionPerformed(ActionEvent e) { IfResult = false; if(tf.getText().trim().indexOf(".") == -1){ tf.setText(tf.getText() + "."); } } } /** * main方法 */ public static void main(String[] args) { new Calculator2().setVisible(true); }}

仅供参考。

温馨提示:内容为网友见解,仅供参考
第1个回答  2012-07-06
没问题。
相似回答