(* This program calculates the area of the circle or the volume and surface area of the sphere. New concepts introduced are functions, procedures, and variables*) PROGRAM practice (input, output); CONST PI = 3.141592654; (*Function calculates circle area*) FUNCTION circleArea (radius : real):real; BEGIN circleArea := PI * radius * radius; END; { circleArea } (*Calculate sphere volume*) FUNCTION sphereVolume (radius : real) : real; BEGIN sphereVolume := 4.0/3.0 * PI * radius * radius * radius; END; (* calculate surfacearea *) FUNCTION sphereSurfaceArea (radius : real):real; BEGIN sphereSurfaceArea := 4 * PI * radius * radius; END; { sphereSurfaceArea } (*calls sphereSurfaceArea and sphereVolume*) PROCEDURE sphereCalc ( radius : real; var volume : real; var area : real); BEGIN volume := sphereVolume (radius); area := sphereSurfaceArea (radius); END; { sphereCalc } BEGIN var radius : real; var sVolume: real; var sArea : real; var choice : char; repeat writeln ('Welcome to circle and sphere calculator'); writeln ('(c)ircle''s surface area'); writeln ('(s)phere''s surface area and volumne.'); writeln ('(q)uit the program'); write ('Enter choice now'); readln (choice); case (choice) of 'C', 'c' : Begin write ('Enter the radius of the circle'); readln (radius); writeln ('The area of the circle with radius ', radius:4:2,' is ', circleArea(radius):4:2); end; 'S', 's': Begin write ('Enter the radius of the sphere'); readln (radius); sphereCalc (radius, sVolume, sArea); writeln ('The surface area of the circle with radius ', radius:4:2,' is ', sArea:4:2, 'and the volume is ',sVolume:4:2 ); end; 'Q', 'q': writeln('Quiting program.'); End; until (choice = 'Q') or (choice ='q'); END.