Advertisement
Vita_Harvey

PA4_A

Feb 1st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. package csc143.newton;
  2.  
  3. /**
  4.  *@author Vita Wiebe
  5.  *@version PA4
  6.  * A simple class to create an object to evaluate the square and cube roots of
  7.  * a given number using the Newton-Raphson algorithm.
  8.  */
  9. public class Roots {
  10.  
  11.     // N, the number whose square or cube root we are trying to guess at
  12.     // or approximate.
  13.     private int N;
  14.    
  15.     /**
  16.      * class constructor.
  17.      * @param int N, the number whose root is being approximated via
  18.      * the Newton-Raphson algorigthm.
  19.      */
  20.     public Roots(int N) {
  21.        new Roots(N);
  22.     }
  23.  
  24.        public double sqrt(double value) {
  25.          value = N;
  26.          value = (value + N/value)/2;
  27.            return value;
  28.        }
  29.    
  30.        public double cbrt(double value) {
  31.            return value;
  32.        }
  33.    
  34.    
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement