The following library functions may be used by one or more of the demonstrations.

Function Description
What it does
Examples
Function isValidInteger(String s) returns Boolean
If the string s represents an integer, the function returns true; otherwise, it returns false.

isValidInteger("-34") returns true

isValidInteger("27.635") returns false

isValidInteger("Hello!") returns false

Function getIntegerValue(String s) returns Integer
If the string s represents an integer, the function return the integer value; otherwise, the program is terminated with an error message.

getIntegerValue("-34") returns -34

getIntegerValue("27.635") creates an error condition

getIntegerValue("Hello!") creates an error condition

Function isValidFloat(String s) returns Boolean
If the string s represents a float, the function returns true; otherwise, it returns false.

isValidFloat("-34") returns true

isValidFloat("27.635") returns true

isValidFloat("Hello!") returns false

Function getFloatValue(s) returns Float
If the string s represents a float, the function return the float value; otherwise, the program is terminated with an error message.

getFloatValue("-34") returns -34.0

getFloatValue("27.635") returns 27.635

getFloatValue("Hello!") creates an error condition.

Function Sqrt(Float x) returns Float
If x >= 0, the function returns the square root of x; otherwise, the program is terminated with an error message.

Sqrt(16) returns 4.0

Sqrt(2.4649) returns 1.57

Sqrt(0) returns 0.0

Sqrt(-7.2) creates an error condition.