用Java编写一个应用程序,要求利用消息对话框输入两个整数,并在信息框中显示这两个数的和与差。谢!
1个回答
展开全部
最简陋的版本...
public class Test
{
public static void main(String[] args) {
int n1 = Integer.parseInt(JOptionPane.showInputDialog("Input number 1: "));
int n2 = Integer.parseInt(JOptionPane.showInputDialog("Input number 1: "));
JOptionPane.showMessageDialog(null, "sum: " + (n1 + n2)
+ "\n" + "difference: " + (n1 - n2));
}
}
public class Test
{
public static void main(String[] args) {
int n1 = Integer.parseInt(JOptionPane.showInputDialog("Input number 1: "));
int n2 = Integer.parseInt(JOptionPane.showInputDialog("Input number 1: "));
JOptionPane.showMessageDialog(null, "sum: " + (n1 + n2)
+ "\n" + "difference: " + (n1 - n2));
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询