Professional Documents
Culture Documents
public static void main(String[] args) { public static void main(String[] args) {
Scanner input=new Scanner(System.in); Scanner input=new Scanner(System.in);
System.out.println("Please enter the number of iterations"); System.out.println("BISECTION METHOD");
int i=input.nextInt(); System.out.println("Please input the first value");
System.out.println("Please input the first value"); double a=input.nextDouble();
double x1=input.nextDouble(); System.out.println("Please input the second value");
System.out.println(" x f(x) f'(x) x2 "); double b=input.nextDouble();
int count=1; double A;
do{ double c, fa,fc,fafc;
double fx= (x1*x1*x1)-(2*x1*x1)-(3*x1)+5; int count=1;
double fbx=(3*x1*x1*x1)-(4*x1*x1)-3; System.out.println("Please input the number of iterations");
double x2=x1-(fx/fbx); int i=input.nextInt();
A=fc*fa;
if(A<0){
a=c;
}
else if(A>0){
b=c;
}
System.out.printf("%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f",
a,b,c,fa,fc,A);
System.out.println("");
count++;
}
while(count<=i);