Hi there,
What i'm trying to accomplish is:
These two methods:
f(x : double) : double
post: return x
integral(og : double, bg : double, step : double) : double
post : return (f(og) + f(og+stap) + … + f(bg)) * step
So I can call those two in my main to calculate the value of the integral of og=0.0, bg=5.0 step=1.0
What I have now is:
public class Opdracht3_1{
public static double f(double x){
return x;
}
public static double integraal(double og, double bg, double stap) {
for(double x = og; x <= bg; x = x + stap) {
double cal = f(og);
og = og+stap;
return cal;
}
}
public static void main(String[] args) {
double og = 0.0; double bg = 5.0; double stap = 1.0;
double cal = integraal(og,bg,stap);
System.out.println(cal);
}
}
The compiler gives the next error:
java:12: missing return statement
}
Any help is appreciated.