Define an interface which has methods area(), volume(). Define constant PI. Create a class cylinder which implements this interface and calculate area and volume.

<?php
interfaceCyl
        {
function area();
function volume();
        }
class Cylinder implements Cyl
        {
public $PI=3.14;
public $a;
public $r;
public $h;
function __construct($r,$h)
           {
                $this->r=$r;
                $this->h=$h;
           }
function area()
           {
              $this->a=2*$this->PI*($this->h*$this->r);
echo"Area = ".$this->a."<br>";
            }
function volume()
           {
              $this->a=$this->PI*$this->r*$this->r*$this->h;
echo"Volume = ".$this->a."<br>";
            }
        }
       $c=new Cylinder(5,5);
       $c->area();
       $c->volume();
?>

Comments

Popular posts from this blog

Create an XML file which gives details of books available in “ABC Bookstore” from following categories. 1)      Technical 2)      Cooking 3)      Yoga And elements in each category are in the following format.     …….     …….     ……. Save the file as “Book.xml” Create an application that reads “Book.xml” file into simple XML object. Display attributes and elements. (Hint:- Use simple_xml_load_file() function). 

Write a PHP program to create a simple calculator that can accept two numbers and perform operations like add, subtract, multiplication and divide (using Self Processing form)

Write an Ajax program to print the content of the myfile.dat. This code asks the user to click a button, fetches data from the server using Ajax techniques and displays that data in the same web page as the button without refreshing the page