- **Java**
(*http://www.velocityreviews.com/forums/f30-java.html*)

- - **Beginner square root question**
(*http://www.velocityreviews.com/forums/t624338-beginner-square-root-question.html*)

Re: Beginner square root questionRay Leon <popeyeray@qwest.net> writes:
>I have the following algorithm >I would appreciate someone to check if this is mostly correct. To check whether it is correct, one needs to compare its actual behavior with the specification for its required behavior. Without a specification, it is »not even wrong«. Also, this is a Java newsgroup, but your post does not refer to Java. |

Beginner square root questionI have the following algorithm
Algorithm Sqrt 1. Input: a real number X If (X < 0) Then Display: X ³ cannot be negative.² STOP Else sqrt(X) = X^0.5 Print ³The square root of X is² sqrt(X) 2. Exit 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 |

Re: Beginner square root questionStefan Ram wrote:
> To check whether it is correct, one needs to > compare its actual behavior with the specification > for its required behavior. To the OP: To expand on this a bit, what is your algorithm supposed to do when X is negative? Obviously, you display "X cannot be negative" and stop, but was that the required behavior? What if in the case of negative number input the algorithm was really supposed to make X positive, take the square root, then display "Ri" to signify an imaginary number? (R = square root.) So, your algorithm is probably correct, but you do need to get the idea down of a specification. Please make sure to tell us first what the algorithm is supposed to do, then give us an implementation to check. It's like those problems in geometry where you're "Given X, Y, Z, show that A is true." Then show the work. You've just shown us the work, we aren't sure what you were given to do. And it would be nice if you included Java in there somehow. |

All times are GMT. The time now is 08:35 PM. |

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.

SEO by vBSEO ©2010, Crawlability, Inc.