public class ComputeAreaWithConsoleInput
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.println("Enter a number for radius:");
double radius=input.nextDouble();
double area=radius*radius*3.1415;
System.out.println("The area for the circle of radius"+radius+"is"+area);
}
}
但是编译出现错误:
对于Scanner,找不到合适的构造器。。。
public class ComputeAreaWithConsoleInput
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter a number for radius:");
double radius = input.nextDouble();
double area = radius * radius * 3.1415;
System.out.println("The area for the circle of radius" + radius + "is"
+ area);
}
}
Enter a number for radius:
1
The area for the circle of radius1.0is3.1415