Question

In: Computer Science

PHP programming language Circle Area, Circumference and ratio:  For a circle with a given radius, write a...

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:

Solutions

Expert Solution

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:


Related Solutions

Write a program that calculates the area and circumference of a circle. It should ask the...
Write a program that calculates the area and circumference of a circle. It should ask the user first to enter the number of circles n, then reads the radius of each circle and stores it in an array. The program then finds the area and the circumference, as in the following equations, and prints them in a tabular format as shown in the sample output. Area = πr2 , Circumference = 2πr, π = 3.14159 Sample Output: Enter the number...
4. By what factor does tripling the radius of a circle increase (a) the circumference of...
4. By what factor does tripling the radius of a circle increase (a) the circumference of the circle? (b) the area of the circle? 5. What are some of the advantages of scientific notation? 6. After which numeral is the decimal point usually placed in scientific notation? What determines the number of numerical digits written in scientific notation?
Discuss the ratio of circumference to diameter for circles on the sphere. the Euclidean radius is...
Discuss the ratio of circumference to diameter for circles on the sphere. the Euclidean radius is the distance to the (Euclidean) center of the circle -- which is not a point on the sphere. But the circle also has a center on the sphere -- this would be the North (or South) Pole for lines of latitude. So the spherical radius of such a circle is different, namely the spherical distance from the (spherical) center. Derive formulas relating these various...
A circle of radius r has area A = πr2. If a random circle has a...
A circle of radius r has area A = πr2. If a random circle has a radius that is uniformly distributed on the interval (0, 1), what are the mean and variance of the area of the circle? Change the distribution of the radius to an exponential distribution with paramter β = 2. Also find the probability that the area of the circle exceeds 3, if it is known that the area exceeds 2.
1) A circle of radius r has area A = π r2. If a random circle...
1) A circle of radius r has area A = π r2. If a random circle has a radius that is evenly distributed in the interval (0, 1), what are the mean and variance of the area of ​​the circle? choose the correct answer A) 1/3 and 1/12 B) Pi/3 and 1/12 C) Pi/3 and 1/5 D) Pi/3 and (4/45)*Pi^2
Write a program, circleref.cpp, that inputs a double radius of circle. It should print, given this...
Write a program, circleref.cpp, that inputs a double radius of circle. It should print, given this radius, the circumference of the circle, the area of the circle, the surface area of a sphere with that radius and the area of a sphere with that radius. Each of its computation functions returns its answers in call by reference parameters. Here are the formulas for computation: Circumference = 2 • π • r Circle Area = π • r2 Sphere Surface Area...
Write a program in C that computes the area of a circle (Area = pi *...
Write a program in C that computes the area of a circle (Area = pi * r2) and the volume of a sphere (Volume = 4/3 * pi * r3). Both formulas use r which is the radius. Declare a float variable pi = 3.14159. Get the value of r from the keyboard and store it in a float variable. Display both the area of the circle and the volume of the sphere.
in Matlab, Use the Monte Carlo analysis to compute the area of a circle with radius...
in Matlab, Use the Monte Carlo analysis to compute the area of a circle with radius 1. print out your code, at least one figure on which the circle and ‘dart hits’ are shown, and numerical results for N=10, 100,1000. For each N, repeat the calculation at least 5times.
Write a program to calculate the area and circumference of a cuboid. Use printf to display...
Write a program to calculate the area and circumference of a cuboid. Use printf to display 2 digits after decimal point in all the results Program should be in java language.
Write a C++ program that prompts the user for the radius of a circle and then...
Write a C++ program that prompts the user for the radius of a circle and then calls inline function circleArea to calculate the area of that circle. It should do it repeatedly until the user enters -1. Use the constant value 3.14159 for π Sample: Enter the radius of your circle (-1 to end): 1 Area of circle with radius 1 is 3.14159 Enter the radius of your circle (-1 to end): 2 Area of circle with radius 2 is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT