Assignment: #NearestSquares |
Due: 04/07/02019 | Points: 3 |

The program prompts the user to enter a positive integer and reads the input into an

intdefined variable. This specification assumes the variable is namedn.Print an error message and exit the program if

nis less than zero.If

nis a square number, print a message sayingnis a square number along with its square root and exit the program.Print the difference between

nand its nearest square number that's less thennand the difference betweennand its nearest square number that's greater thann. In addition, print the two nearest square numbers along with their respective square roots.Example inputs/outputs. [Note: User inputs are in bold.]

Enter a positive integer:2001-65...24 [sqrt(1936)=44...sqrt(2025)=45] Enter a positive integer:71-7...10 [sqrt(64)=8...sqrt(81)=9] Enter a positive integer:1616 is a square number [sqrt(16)=4] Enter a positive integer:213-17...12 [sqrt(196)=14...sqrt(225)=15]## Class Math

Docs.Oracle.com::class Math

Your program can use the

sqrt(n)andfloor(n)static methods defined in theMathclass.Your program is not allowed to use the

Math.pow(n)static method.## Typecasting

The

typecastoperator()is used to change the data type of a variable when used in an expression.Example typecast usages.

The argument

ntoMath.sqrt(n)is defined to be typedouble. Ifnis typeint, then use a typecast.double y =Math.sqrt((int)n)The return value of

Math.floor(x)is defined to be typedouble. If the return value is to be assigned to a variable namenof typeint, then use a typecast.int n =(int)Math.floor(y)