ComputeArea2

这是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 );
		
	}

}


 

ComputeArea2_第1张图片

ComputeArea2_第2张图片

你可能感兴趣的:(ComputeArea2)