Input/Output Can not find symbol

Johynboy05

Mitglied
Java:
import java.util.ArrayList;
public class B{
    public static double getValue(double x){
        return Math.pow(x,3)-6*Math.pow(x,2)+3*x+10;
    }
    public static double getDerivative(double x){
        return 3*Math.pow(x,2)-12*x+3;
    }
    public static double getZero(double x,double eps,int max){
        double xn=x;
        double y = eps + 1; //Differenz der Iterationsschritte. Mit dem Startwert wird sichergestellt, dass bei 0 Iterationen nichts gefunden wird
        for(int c=0;c<=max;c++){
            double xn1=xn-getValue(x)/getDerivative(x);
            y=Math.abs(xn - xn1); //Differenz berechnen
            xn=xn1;
        }
        if(y<=eps)return xn;
        else return Double.NaN();

[LIST]
[*]                           :oops: 
[/LIST]
     }
    public static void main(String[] args){
        double eps=Math.pow(10,-6);
        System.out.print("MAX_ITERATIONS = ?");
        int max=SavitchIn.readLineInt();
        ArrayList<Double> nullstellen = new ArrayList<Double>();
        for(double x=-10;x<=10;x+=0.1){
            double cZ=getZero(x,eps,max);
            if(Double.isNaN(cZ)) continue;
            boolean nullstelleSpeichern = true; 
              for (Double d : nullstellen) {
                if (Math.abs(d - cZ) < eps) { 
                    nullstelleSpeichern = false;
                }
            }
            if (nullstelleSpeichern) { 
                nullstellen.add(cZ);
                   System.out.println(cZ); 
            }
        }
    }
}

Das ist mein code und zwar wenn ich jetz compiliere bekomme ich immer die meldung :
cannot find symbol
else return Double.NaN();
^
hat einer ne idee danke!!


 
Zuletzt bearbeitet von einem Moderator:

Neue Themen


Zurück
Oben