import java.util.Scanner; /*******************************************************************************/ /** * This is the main class for a Newton's method root finding program. * * @author Duncan Buell * 24 February 2008 **/ public class Main { public static void main (String[] args) { double epsilon,root,x; Scanner console = new Scanner(System.in); Newton newtonRootFinder = new Newton(); System.out.println("Enter the tolerance epsilon for successive approximations: "); epsilon = console.nextDouble(); if(epsilon <= 0) { System.out.println("ERROR: Input value " + epsilon + " for epsilon is not positive"); System.exit(0); } System.out.println("Enter the initial guess for the root: "); x = console.nextDouble(); System.out.println("Start with an initial guess for the root of " + x); System.out.println("Stop when the difference between successive approximations is < " + epsilon); root = newtonRootFinder.findRoot(x,epsilon); System.out.println("Approximate root of the function is " + root); System.out.println("Program terminating normally"); } } // public class Main