## can any one give me the source code using java?

45 pts.
Tags:
Application development
Java
Write a function named isSquare that returns 1 if its integer argument is a square of some integer, otherwise it returns 0. Your function must not use any function or method (e.g. sqrt) that comes with a runtime library or class library! The signature of the function is int isSquare(int n) Examples: if n is return reason 4 1 because 4 = 2*2 25 1 because 25 = 5*5/td> -4 0 because there is no integer that when squared equals -4. (note, -2 squared is 4) 8 0 because the square root of 8 is not an integer. 0 1 because 0 = 0*0

Thanks. We'll let you know when a new response is added.

If you cannot use ANY function, your function should look something like this:

<pre> public int isSquare (int n) {
int iRootTest = 1;
int iSquareTest = 0;
if (n == 0 || n == 1)
return 1;
while (iSquareTest <= n) {
iSquareTest = iRootTest*iRootTest;
if (iSquareTest == n)
return 1;
iRootTest += 1;
};
return 0;
};</pre>

This function will try any integer starting from 1 until the square of that integer is equal or greater than n. If it is equal, then return 1, and when it is bigger exits from the loop and return 0;