帮忙看看!!最后二句为什么出错?
public static void main(String[] args) {String input = JOptionPane.showInputDialog("请输入第一个数");
double number1 = Double.parseDouble(input);
String operator = JOptionPane.showInputDialog("请输入操作符");
input = JOptionPane.showInputDialog("请输入第二个数");
int number2 = 0;
double number3 = 0;
if ("^".equals(operator)) {
number2 = Integer.parseInt(input);
} else {
number3 = Double.parseDouble(input);
}
if ("+".equals(operator)) {
JOptionPane.showMessageDialog(null, number1 + number3 + " ");
} else if ("-".equals(operator)) {
JOptionPane.showMessageDialog(null, number1 - number3 + " ");
} else if ("*".equals(operator)) {
JOptionPane.showMessageDialog(null, number1 * number3 + " ");
} else if ("/".equals(operator)) {
JOptionPane.showMessageDialog(null, number1 / number3 + " ");
} else if ("%".equals(operator)) {
JOptionPane.showMessageDialog(null, number1 % number3 + " ");
} else if ("^".equals(operator)) {
double result = 1.0;
}
for (int i = 0; i < number2; i++) {
}
result *= number1;
JOptionPane.showMessageDialog(null, result + " ");
}
}
最后二句中的RESULT出现错误!!如果把最后二句删了程序也可以运行搞不懂了,能不能把这个程序每句解释下,谢谢~~