// The "FunctionTypeMethod" class.
public class FunctionTypeMethod
{
public static void main (String[] args)
{
// EXAMPLE 1:
// this function takes a real value and doubles it
// function doubleIt (x: real ) : real
// result 2.0 * x
// end doubleIt
// MAIN PROGRAM IN TURING:
// put doubleIt ( 5.3) % this outputs 5.3 * 2 or 10.6
System.out.println ("This is the return value of the 'doubleIt' function: "
+ doubleIt (20.5));
System.out.println ("This is the end of the 'doubleIt' function program!");
} // main method
// returns a double-type value that is twice the value passed to it (20.5)
public static double doubleIt (double x)
{
return 2.0 * x;
} // doubleIt method
} // FunctionTypeMethod class
No comments:
Post a Comment