我的程序有问题。程序显示第一个JOption消息对话框,但是当你输入一个值时,它不能显示第二个对话框?基本计算器
import java.util.Scanner;
import javax.swing.JOptionPane;
public class javaCalculator
{
public static void main(String[] args)
{
int num1;
int num2;
String operation;
Scanner input = new Scanner(System.in);
JOptionPane.showInputDialog(null,"please enter the first number");
num1 = input.nextInt();
JOptionPane.showInputDialog(null,"please enter the second number");
num2 = input.nextInt();
JOptionPane.showInputDialog(null,"Please enter operation");
operation = input.next();
if (operation.equals ("+"))
{
JOptionPane.showMessageDialog(null,"your answer is" + " " + (num1 + num2));
}
if (operation.equals ("-"))
{
JOptionPane.showMessageDialog(null,"your answer is" + " " + (num1 - num2));
}
if (operation.equals ("/"))
{
JOptionPane.showMessageDialog(null,"your answer is" + " " + (num1/num2));
}
if (operation.equals ("*"))
{
JOptionPane.showMessageDialog(null,"your answer is" + " " + (num1 * num2));
}
}
}
然后操作可能*不*等于任何操作字符串 - 什么是* *是真的吗? (另外,考虑使用'System.out.println'作为控制台应用程序..你正在从控制台读取数据,所以不妨写信给它: - /) – 2013-02-06 01:54:34
而且,*这个程序是如何启动的?用'java'或'javaw'? – 2013-02-06 02:01:16