square root sqrt algorithm and flowchart

Discussion in 'Java' started by popeyerayaz, Jul 8, 2008.

  1. popeyerayaz

    popeyerayaz Guest

    I am a complete beginner and have the following instructions:

    Develop a algorithm and flowchart that enables a user to choose one of
    the following types of calculations to
    perform on an input number.

    Calculate the square of the number
    Calculate the cube of the number
    Round the number to two decimal places
    Calculate the square root of the number

    I only had to choose one and chose the "Calculate the square root of
    the number".
    I have the following algorithm

    Algorithm

    1. Input: a real number X
    sqrt(x) = x^0.5
    2. If (X < 0) Then
    Output: X “ cannot be negative.”
    STOP
    Edif

    My flowchart is on the following web page:
    http://www.popeyeray.com/lesson6.htm

    I would appreciate someone to check if this is mostly correct.
    I also am not sure about the error message and how to put it into my
    flowchart.

    Thank you
    Ray
     
    popeyerayaz, Jul 8, 2008
    #1
    1. Advertising

  2. popeyerayaz

    Roedy Green Guest

    On Mon, 7 Jul 2008 16:28:36 -0700 (PDT), popeyerayaz
    <> wrote, quoted or indirectly quoted someone who
    said :

    >1. Input: a real number X
    >sqrt(x) = x^0.5
    >2. If (X < 0) Then
    >Output: X “ cannot be negative.”
    >STOP
    > Edif


    that is not what they were thinking of. They were thinking of a loop
    that gradually homes in on the answer.

    they were probably expected you to code something like this based on
    elementary differential calculus.
    http://en.wikipedia.org/wiki/Fractional_calculus


    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Jul 8, 2008
    #2
    1. Advertising

  3. On Mon, 07 Jul 2008 16:28:36 -0700, popeyerayaz wrote:

    >
    > I only had to choose one and chose the "Calculate the square root of
    > the number".
    > I have the following algorithm
    >

    Read the requirement more carefully. It says the USER of your algorithm
    makes the choice, not you. Your algorithm must include that as well as
    ways of doing all four calculations.

    Comp.Sci. 101 is learning to read and understand what the requirement
    actually says, not what you think it says.

    >
    > I would appreciate someone to check if this is mostly correct.
    > I also am not sure about the error message and how to put it into my
    > flowchart.
    >

    So, no your answer is not correct because you've left out most of the
    requirement.


    --
    martin@ | Martin Gregorie
    gregorie. |
    org | Zappa fan & glider pilot
     
    Martin Gregorie, Jul 8, 2008
    #3
  4. popeyerayaz

    Arne Vajhøj Guest

    Roedy Green wrote:
    > On Mon, 7 Jul 2008 16:28:36 -0700 (PDT), popeyerayaz
    > <> wrote, quoted or indirectly quoted someone who
    > said :
    >> 1. Input: a real number X
    >> sqrt(x) = x^0.5
    >> 2. If (X < 0) Then
    >> Output: X “ cannot be negative.”
    >> STOP
    >> Edif

    >
    > that is not what they were thinking of. They were thinking of a loop
    > that gradually homes in on the answer.
    >
    > they were probably expected you to code something like this based on
    > elementary differential calculus.
    > http://en.wikipedia.org/wiki/Fractional_calculus


    Considering the other tasks:
    Calculate the square of the number
    Calculate the cube of the number
    Round the number to two decimal places

    Then it seems as a good guess that Math.sqrt would be
    sufficient !

    Arne
     
    Arne Vajhøj, Jul 13, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,255
  2. David Harmon
    Replies:
    2
    Views:
    2,925
    cplusplus
    Jun 14, 2006
  3. david ullua
    Replies:
    9
    Views:
    1,452
    Stefan Ram
    Feb 5, 2007
  4. Clint Olsen
    Replies:
    2
    Views:
    376
    Clint Olsen
    Mar 22, 2005
  5. Blue sky

    The problem with square and sqrt function

    Blue sky, Nov 4, 2008, in forum: C Programming
    Replies:
    6
    Views:
    444
    Flash Gordon
    Nov 5, 2008
Loading...

Share This Page