put "--------------------------------------------------------------------------------" %80 Dashes
put "Welcome to Edward Yang's circumference and area of a circle calculator." %Made at 10:22 pm 2/21/13
put " "
put "Please enter 1 for the first prompt, and 1 for the second if you would like to have only circumference calculated."
put " "
put "Please enter 1 for the first prompt, and 2 for the second if you would like to have only the area of a circle calculated."
put " "
put "Please enter 2 for the first prompt, and 1 for the second if you would like to have both of the above calculated."
var p1, p2, p3 : int %Prompt 1: 2*pi*r
put " " %Prompt 2: Pi*R**2
put "Prompt #1: " .. %Prompt 3: Both above
get p1
put "Prompt #2: " ..
get p2
put "--------------------------------------------------------------------------------"
procedure greet
var r : real
put "If you have the length of the diameter, divide it by two to get the radius."
put "--------------------------------------------------------------------------------"
put "Enter the length of the radius here: " ..
get r
put "--------------------------------------------------------------------------------"
end greet
put "Note: Do not state the units you are using. Just input the numbers. If you have the length of the diameter, divide it by 2 to get the radius."
put "--------------------------------------------------------------------------------" % 80 dashes.
const pi : real := 3.14
%Prompt #1
if p1 = p2 then
greet
put "C=2*Pi*R"
put "C=2*", pi, "*", r
put "C=", 2 * pi * r
put "The circumference of the circle is ", 2 * pi * r, "."
put "--------------------------------------------------------------------------------"
%Prompt #2
elsif p1 < p2 then
greet
put "A=Pi*R**2"
put "A=", pi, "*", r, "**2"
put "A=", pi, "*", r ** 2
put "A=", pi * (r ** 2)
put "The area of the circle is ", pi * (r ** 2)
%Prompt #3
else
greet
put "C=2*Pi*R"
put "C=2*", pi, "*", r
put "C=", 2 * pi * r
put "The circumference of the circle is ", 2 * pi * r, "."
put "--------------------------------------------------------------------------------"
put "A=Pi*R**2"
put "A=", pi, "*", r, "**2"
put "A=", pi, "*", r ** 2
put "A=", pi * (r ** 2)
put "The area of the circle is ", pi * (r ** 2)
put "--------------------------------------------------------------------------------"
end if
|