题目write a method IsCircleBigger which accepts three double parameters,rad,wid,and len, and gives a boolean answer to the following question:
Does a cicle with rad have a greater area than a retangle with wid and len?
我写的代码
public static void IsCircleBigger (double rad,double wid,double len) {
boolean answer = false;
double CircleArea;
double RectangleArea;
double r;
double width;
double length;
String input ;
input = JOptionPane.showInputDialog("enter a radius");
r=Double.parseDouble (input);
CircleArea= Math.pI *r*r;
input = JOptionPane.showInputDialog("enter a width ");
width=Double.parseDouble (input);
input = JOptionPane.showInputDialog("enter a length ");
length=Double.parseDouble (input);
RectangleArea = width *length;
if(CircleArea>RectangleArea) {
System.out.println("yes");
else{
System.out.println("NO");
}
}
不知道对不对!