Essentially my delta value is giving me some trouble, when I print all the variables to the console window everything is right and proper except for delta, whose value keeps showing up as NaN. I can't for the life of me figure out why. I am a beginning CIS student at a University and this is really giving me a headache.
import java.util.Scanner;
public class ReimannSumCalculator {
static double a,b,c,start,end;
static double partitions;
static double delta=end - start / partitions;
private static double Quadratic(double a,double b,double c,double x) {
double Quadratic = a*x*x + b*x + c;
return Quadratic;
}
public static void leftReiman(double a,double b,double c,double delta,double start,double end) {
double leftReiman = 0;
for(double x = start; x<end; x+=delta) {
leftReiman = delta * Quadratic(a,b,c,x) + leftReiman;
}
System.out.println("Your left Reiman sum is " + leftReiman);
}
public static void rightReiman(double a,double b,double c,double delta,double start,double end) {
double rightReiman = 0;
for(double x = start+delta; x<=end; x+=delta) {
rightReiman = delta* Quadratic(a,b,c,x) + rightReiman;
}
System.out.println("Your right Reiman sum is " + rightReiman);
}
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter some values for a b and c.");
a = keyboard.nextDouble();
b = keyboard.nextDouble();
c = keyboard.nextDouble();
System.out.println("Please enter a start and end point.");
start = keyboard.nextDouble();
end = keyboard.nextDouble();
System.out.println("Now enter the amount of partitions.");
partitions = keyboard.nextInt();
leftReiman(a,b,c,start,end,delta);
rightReiman(a,b,c,start,end,delta);
System.out.println("The delta is: " + delta);
System.out.println("The amount of partitions are: " + partitions);
System.out.println("a is: "+ a);
System.out.println("b is: "+ b);
System.out.println("c is: " + c);
System.out.println("The start is: " + start);
System.out.println("The end is: " + end);
}
}