In: Computer Science
PHP programming language Circle Area, Circumference and ratio: For a circle with a given radius, write a program to compute 1) area of the circle, 2) circumference of the circle and 3) the ratio of the circumference to its diameter. You will use 3 different values of radius a) 10cm, b) 50 cm, and c) 100cm for your computations. The output should print or echo the following statements identifying the writer of the program and the computation for each value of the radius. Example: "This program was created by $Yourname. The area of the circle with radius 10cm is 314 square centimeters. Its circumference is 62.8cm and the ratio of its circumference to its diameter is 3.14" . You will use variables to store the values of for each radius and for your computations along with your name. Save the php file with yourlastnameCircle.php and also add your name in the comments section of the program. Following are the formulas needed for computation:
Code:
<?php
$radius = 10.0;
$pi = 3.14159;
$area = $pi * $radius * $radius;
$circumference = $pi*2*$radius;
$ratio = $circumference/(2*$radius);
echo("This program was created by Yourname");
echo("\nTh area of circle with radius ".$radius . "cm is: " .$area." square centimeters");
echo("\nIts circumference is ".$circumference."cm");
echo("\nthe ratio of the circumference to its diameter is ".$ratio);
?>
Output: