Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package csc143.newton;
- /**
- *@author Vita Wiebe
- *@version PA4
- * A simple class to create an object to evaluate the square and cube roots of
- * a given number using the Newton-Raphson algorithm.
- */
- public class Roots {
- // N, the number whose square or cube root we are trying to guess at
- // or approximate.
- private int N;
- /**
- * class constructor.
- * @param int N, the number whose root is being approximated via
- * the Newton-Raphson algorigthm.
- */
- public Roots(int N) {
- new Roots(N);
- }
- public double sqrt(double value) {
- value = N;
- value = (value + N/value)/2;
- return value;
- }
- public double cbrt(double value) {
- return value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement