#
# Program to calculate the circumference of circle
# The constant variable of PI
$pi = 3.14159265;
# This section is to calculate the circumference of circle
# (whose radius is 12.5)
$radius = 12.5;
$cc = 2*$pi*$radius;
print $cc;
print "\n";
print "The circumference of circle(radius=$radius): $cc\n";
print "The circumference of circle(radius=".$radius."): ".$cc."\n";
# This section is to calculate the circumference of circle,
# which the radius of circle inputed from termine by user.
# So, pls enter the radius of circle while "Pls input the radius of circle".
# User can exit the program by click <ENTER> key.
print "Pls input the radius of circle:";
while ($radius = <STDIN>) {
if ($radius eq "\n") {
print "exit";
last;
}
if ($radius < 0) {
print "Warn: The radius of circle can not be less than zero(0)\n";
$cc = 0;
} else {
$cc = 2*$pi*$radius;
}
print "The circumference of circle(radius=".$radius."): ".$cc."\n";
#continue yes/no
print "Pls input the radius of circle:";
}