/* * Main.java * * Created: January 29, 2005 * By: Stan Sclaroff * Description: Main class to help test methods developed for * CS111 Spring 05 Programming Assignment 2 * */ package program2; public class Main { /** Creates a new instance of Main */ public Main() { } /** * @param args the command line arguments */ public static void main(String[] args) { MyMath m = new MyMath(); // uncomment the next line if you want debugging mode on // m.debug(true); // Some test cases that will be used in grading... double root; // Case 1: 4th root of 81 is 3 root = m.nRootBisection(81.0,4); System.out.println("4th root of 81 is 3, Bisection estimates " + root); root = m.nRootNewton(81.0,4); System.out.println("4th root of 81 is 3, Newton estimates " + root); // Case 2: 6th root of 15625 is 5 root = m.nRootBisection(15625.0,6); System.out.println("6th root of 15625 is 5, Bisection estimates " + root); root = m.nRootNewton(15625.0,6); System.out.println("6th root of 15625 is 5, Newton estimates " + root); // Case 3: 3rd root of 0.125 is 0.5 root = m.nRootBisection(0.125,3); System.out.println("3rd root of 0.125 is .5, Bisection estimates " + root); root = m.nRootNewton(0.125,3); System.out.println("3rd root of 0.125 is .5, Newton estimates " + root); // Case 4: 10th root of 1024 is 2 root = m.nRootBisection(1024.0,10); System.out.println("10th root of 1024 is 2, Bisection estimates " + root); root = m.nRootNewton(1024.0,10); System.out.println("10th root of 1024 is 2, Newton estimates " + root); // Test two of the error cases if(m.nRootNewton(-9,2) == -1) System.out.println("Error case correctly detected: Negative y"); else System.out.println("Error case not detected: Negative y"); if(m.nRootNewton(7,-2) == -1) System.out.println("Error case correctly detected: Negative n"); else System.out.println("Error case not detected: Negative n"); // Feel free to write additional tests here... // Keep in mind that you do not submit Main.java in this assignment. } }