求一个 JAVA用窗口实现两数相加程序

来源:百度知道 编辑:UC知道 时间:2024/05/27 19:19:15

import javax.swing.JOptionPane;

public class Add {
public static void main(String[] args) {
String first = JOptionPane.showInputDialog("first number : ");
String second = JOptionPane.showInputDialog("second number : ");
double no1 = Double.parseDouble(first);
double no2 = Double.parseDouble(second);

double result = no1 + no2;
JOptionPane.showMessageDialog(null,result);
}
}

public class A
{
public static void main(String str[])
{
int a=20;
int b=10;
System.out.println(a+b);
}
}