{{ Sample Juli program {{ Jeff LeFevre #1723 {{ jlefevre@csee.usf.edu {{ Dr Albrecht {{ COP 4020 {{ December 6, 2002 {{ Edited by Kevin Albrecht in Jan 2003 to work with Juliet 2004.0 {{ Program to calculate : {{ Volume of a sphere {{ Volume of a pyramid {{ Volume of a cube $lib rout main def doagain:int <- 1 {{ flow control variables def temp:str def choice:int def again:str <- " y" def radius:rat {{ for sphere def length:rat, width:rat, height:rat {{ for pyramid def side:rat {{ for cube def answer:rat {{ for all loop doagain = 1 {{ begin main loop doagain <- 0 {{ to break out of loop by default on next iteration print nl printn "(1) Volume of a sphere" printn "(2) Volume of a pyramid" printn "(3) Volume of a cube" print "Which of the above would you like to calculate?: " choice <- readi print nl cond choice = 1 {{ calculate volume of a sphere print "Please enter the radius of the sphere: " radius <- readr answer <- (4.0/3.0) * pi * radius * radius * radius print "The volume of the given sphere is: " print str answer cond choice = 2 {{ calculate volume of a pyramid print "Please enter the length of the base: " length <- readr print "Please enter the width of the base: " width <- readr print "Please enter the height of the pyramid: " height <- readr answer <- (1.0/3.0) * length * width * height print "The volume of the given pyramid is: " print str answer cond choice = 3 {{ calculate volume of a cube print "Please enter the length of a side: " side <- readr answer <- side * side * side print "The volume of the given cube is: " printn str answer cond (choice <> 1) and (choice <> 2) and (choice <> 3) printn "-- Invalid choice --" print nl print nl print "Would you like to continue (y/n)? " {{ for loop flow control temp <- reads cond temp = "y" doagain <- 1 {{ end of main loop