Import JJIO Class FunctionExamples -- Name Anonymo Us -- Does Show many function methods Routine Tester (none) is public Boxes a,b,c ofType real Boxes i,j,k ofType int -- Does test of functions Start Outputln "Enter a positive real " Input a Outputln a Outputln "The rounded value is " Outputln round(a) Outputln " " -- gap EndRoutine Tester Function round (r) ofType int is public Slot r ofType real Box result ofType int -- Does: round off a real to closest integer Set result = RealToInt (r + 0.5) EndFunction round Function secant (degrees) ofType real is public Slot degrees ofType real Box result ofType real -- Does return the reciprocal of cosine -- Assert cos(degrees) != 0 Set result = 1.0 / Cos (degreesToRadians(degrees)) EndFunction secant Function degreesToRadians (degrees) ofType real is public Slot degrees ofType real Box result ofType real -- Does convert degrees to radians, for trig funcs Set result = degrees * 3.14159 / 180.0 EndFunction degreesToRadians Function triArea (a,b,c) ofType real is public Slot a ofType real -- the 3 sides Slot b ofType real -- of any Slot c ofType real -- triangle Box result ofType real Boxes s, t ofType real -- Does: use Hero's formula Set s = (a + b + c) / 2.0 Set t = s * (s-a) * (s-b) * (s-c) Set result = Sqrt( t ) EndFunction triArea Function odd (i) ofType bool is public Slot i ofType int Box result ofType bool -- Does: indicate if int i is odd Set result = ((i % 2) == 1) EndFunction odd EndClass FunctionExamples