dimanche 1 octobre 2017

java incompatible type error else-if statement

im only trying to compute for the three values and not sure what to put as my else statement. i put return but it just keeps giving me an incompatible type error. ive tried setting it as null, and NaN but it states i cant do that with the type being double. any help is appreciated.

public static double getE(int i) {
    double e = 1, x=1;
for(i = 1; i <= 100000; i++){
  x=x/i;
  if (i == 10000) {
    return x;
}
  else if (i == 20000) {
    return x;
}
  else if (i == 100000) {
    return x;
    } 
return;

}
}

Aucun commentaire:

Enregistrer un commentaire