Results 1 to 3 of 3
  1. #1
    colerelm is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default I don't get what this is asking me to do...

    I have an assignment out of my Java book and I'm not asking for anyone to code anything for me but I am asking if anyone can clarify what the book is trying to have me accomplish:

    20. The following defines a function that calculates an approximation of the square root of a number, starting with an approximate answer(approx), within the specified tolerance(to1).


    {approx | if|approx^2 - number| <= tol
    sqrRoot(number,approx,tol) = {sqrRoot(number,(number^2 + number) / (2* approx), tol) | if|approx^2 - number | > tol

    Write a recursive and non-recursive method of the sqrRoot method.

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Re: I don't get what this is asking me to do...

    Are you sure you copied this code correctly? Please use proper indentation to make it easier for us to read. It looks like they want you to write two methods on calculating a method which finds the square root of some number.

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,655
    Blog Entries
    7
    Rep Power
    21

    Default Re: I don't get what this is asking me to do...

    Quote Originally Posted by colerelm View Post
    Java Code:
                                            {approx                                                                       | if|approx^2 - number| <= tol                                     
    sqrRoot(number,approx,tol) = {sqrRoot(number,(number^2 + number) / (2* approx), tol)   | if|approx^2 - number | > tol
    Cute; what language is this? It doesn't mind unbalanced brackets ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •