double root(0.0,10.0,0.001,double h3pie);
你这是定义一个double[]类型的数组呢?还是有其它的意义?从来没看到过这样的定义。
return x1-(x2-x)*Math.tan(55*Math.PI/180)/12*(2*Math.pow(x2,2)+
        2*x2*x+2*Math.pow(x,2);
后面少了个符号")"
class Csc csc=new Csc(); 
哪有这样实例化的?去掉class

解决方案 »

  1.   

    仔细看了看你double root(0.0,10.0,0.001,double h3pie);的意思是调用root方法。但是很明显语法错误。
    1,root方法返回一个double值,所以你必须定义一个double类型的变量调用它才行。
    2,root方法的参数可以是变量,但必须保证变量已得到初始化,而h3pie才定义,错误。
    改为:
    double h3pie = 0.0;
    double dbname = root(0.0,10.0,0.001,h3pie);
      

  2.   

    关于double root(0.0...)
    我解释一下,
    你可以在后面看见对方法root()的定义
    上面只不过是调用
    还有,由于Java 支持向前引用
    (先调用,在定义)
    所以我觉得应该没问题
    后两个,我改正了!
      

  3.   

    提个意见,这个interface Index1 似乎从设计上来看,用class应该正确一点。
      

  4.   

    关于root 的错误我已改正,
      

  5.   

    to eyeieye
    :
    你说的非常对:
    程序出错提示:不可引用static的变量!
      

  6.   

    又有错误:
    non-static variable velocity cannot be referenced from a static context
      double A=...
      

  7.   

    你的意思是我用的root()是静态函数?
    从那看出他是的??
    我再把修改后的给大家看一下://:Csc.java
    //computing the sedimenting tank;
    import java.io.*;
    import Geshan.*;class Index1{
      double velocity=0.2;//设计流量时的水平流速,米/秒
      double time=50;//最大设计流量时,污水在池内的停留时间,秒
      double maxQ=Index.kTotal*20000.0/86400;//最大流量
      double h2=1;//设计有效水深,米
      double day=2;//计算沉砂斗体积时,按2天的沉砂量计,天
      double x1=3;//城市污水沉沙量,立方米/十万立方米
      double a1=0.5;//沉砂斗下底宽,米
      double alpha=55;//沉砂斗壁与水平面的倾角,度
      double n=4;//沉砂斗的个数
      double minQ=20000.0/86400/3;
      double po=0.06;//沉砂斗外侧的坡度
    //  double h3=0.7;沉砂斗的高度,米
      
    }
       
    public class Csc { 
      
        double L1=Index1.velocity*Index1.time;//水流部分长度,米
        double A=Index1.maxQ/Index1.velocity;//水流断面积,平方米
        double B=A/Index1.h2;//池总宽度,米
        double V=86400*Index1.maxQ*Index1.day*Index1.x1/(100000*Index.kTotal);
                //沉砂斗容积,立方米
        double v=V/Index1.n;//每个沉砂斗的容积,立方米
        double h3pie=0.0;
        double rr=root(0.0,10.0,0.001,h3pie);
        double a=2*h3pie/Math.tan(Index1.alpha*Math.PI/180)+Index1.a1;
                //沉砂斗上口宽,米
        double h3=h3pie+Index1.po*(L1-Index1.n/2*a)/2;//沉砂室总高,米
        double H=Index1.h2+Index1.h2+h3;//沉砂池总高,米
        double minV=Index1.minQ/(B/2*Index1.h2); 
        
        
        double f(double x,double x1,double x2){
         return x1-(x2-x)*Math.tan(55*Math.PI/180)/12*(2*Math.pow(x2,2)+
            2*x2*x+2*Math.pow(x,2));
        }
        double root(double y1,double y2,double y3,double y4){
          double s1=f(y1,v,Index1.a1);
          y4=(y1+y2)/2;
          while (Math.abs(y2-y1)>y3){
            
            double s2=f(y4,v,Index1.a1);
            if(s2+1.0==1.0){
              return y4;
            }
            if (s1*s2>0){
              double y5=y4;
            }
            else{
              double y6=y4;
            }
            y4=(y5+y6)/2;
          }
         
        }
        
      public static void main(String[] args){
        Csc csc=new Csc(); 
        try {
          DataOutputStream out2 =
            new DataOutputStream(
              new BufferedOutputStream(
                new FileOutputStream("Data.txt")));
          out2.writeDouble(L);
          out2.writeDouble(A);
          out2.writeDouble(B);
          out2.writeDouble(V);
          out2.writeDouble(h3pie);
          out2.writeDouble(a);
          out2.writeDouble(h3);
          out2.writeDouble(H);
          out2.writeDouble(minV);
          out2.writeDouble(Index.kTotal);
          out2.close();
          DataInputStream in5 =
            new DataInputStream(
              new BufferedInputStream(
                new FileInputStream("Data.txt")));
          
          // Must use DataInputStream for data:
          System.out.println("L="+in5.readDouble());
          System.out.println("A="+in5.readDouble());
          System.out.println("B="+in5.readDouble());
          System.out.println("V="+in5.readDouble());
          System.out.println("h3pie="+in5.readDouble());
          System.out.println("a="+in5.readDouble());
          System.out.println("h3="+in5.readDouble());
          System.out.println("H="+in5.readDouble());
          System.out.println("minV"+in5.readDouble());
          System.out.println("kTotal="+in5.readDouble());
        } catch(EOFException e) {
          System.out.println("End of stream");
        }
      }
    }///:~