这是ComputeArea的改进版,增加了手动输入的操作
import javax.swing.*; public class ComputeArea { public static void main(String args[]) { final double PI=3.14159;//常量PI double area; int y; String s=(String)JOptionPane.showInputDialog(null,"请输入一个数","输入对话框", JOptionPane.PLAIN_MESSAGE,null,null,null); y=Integer.parseInt(s); area=PI*y*y;//圆的面积 System.out.println("The area for the circle of y is "+area ); } }