Slip no. 15. Write a PHP program
to define Interface shape which has two method as area() and volume (). Define
a constant PI
Create a class Cylinder
implement this interface and calculate area and Volume.
HTML file :
<html>
<body>
<center>
<h2>
Calculate area and value of cylinder</h2>
<form
action="slip1_demo.php" method="GET">
<h3> Enter radius : <input type=text
name=r><br> </h3>
<h3> Enter height : <input type=text
name=h><br><br> </h3>
<input
type=submit value=submit name=Show>
<input
type=reset value=Reset name=Reset>
</form>
</center>
</body>
<html>
PHP file :
<?php
$r = $_GET['r'];
$h = $_GET['h'];
define('PI','3.14');
interface cal
{
function
area($r,$h);
function
vol($r,$h);
}
class cylinder implements cal
{
function
area($r,$h)
{
$area =
2*PI*$r*($r+$h);
echo
"<h3>The area of cylinder is :$area</h3>";
}
function
vol($r,$h)
{
$vol =
PI*$r*$r*$h;
echo
"<h3>The volume of cylinder is :$vol</h3>";
}
}
$c = new cylinder;
$c->area($r,$h);
$c->vol($r,$h);
?>
Most valuable article. Really I got more knowledge from this article. Thanks.
ReplyDeletePlacement Training in Chennai
Training institutes in Chennai with placement
Placement Training in Velachery
soft skills training in chennai
soft skills training
clinical sas training in chennai
SAS Training in Chennai