public class L_S{
public static void main(String args[]){
   double a=0.0,b=0.0;
   if(args.length==1)
   a=b=Integer.parseInt(args[0]);
   if(args.length>1)
      {a=Integer.parseInt(args[0]);
       b=Integer.parseInt(args[1]);
      }
    Rectangle f=new Rectangle(a,b);
    f.l_s();   
      }
}class Rectangle{
private double width,heigth;
Rectangle (double i,double j){
width=i;
heigth=j;
}

public void l_s(){
double l,s; 
l=2*(width+heigth);
s=width*heigth;
System.out.println("l="+l+"\0s");
}
}

解决方案 »

  1.   

    你的程序错误很多,我帮你纠正过来了,你自己慢慢看一下吧!!public class L_S{
    public static void main(String args[]){
       //double a,b;
       int a=0,b=0;
       if(args.length==1)
       a=b=Integer.parseInt(args[0]);
       if(args.length>1)//ags改为args
          {a=Integer.parseInt(args[0]);
           b=Integer.parseInt(args[1]);
          }
        Rectangle f=new Rectangle(a,b);
        f.l_s(); 
    }}class Rectangle{
    private int width,heigth;
    Rectangle (int i,int j){
    width=i;
    heigth=i;
    }

    public void l_s(){
    double l,s; 
    l=2*(width+heigth);
    s=width*heigth;
    System.out.println("l="+l+"\0s");
    }
    }