Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package proj1;
- import java.util.Scanner;
- public class P42
- {
- private static final double eps = (double) 1E-15 ;
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- System.out.println ("a = ");
- double a = in.nextInt();
- System.out.println ("b = ");
- double b = in.nextInt();
- System.out.println ("c = ");
- double c = in.nextInt();
- System.out.println ("x0 = ");
- double x = in.nextInt();
- double y = x - (a*x*x+b*x+c)/(2*a*x+b) ;
- int k = 1;
- while (y - x < eps )
- {
- x = y ;
- y = x - (a*x*x+b*x+c)/(2*a*x+b) ;
- k ++;
- }
- System.out.println ( "Xn = " + x +'\n' + "Xn+1 = " + y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement