Solution:
slip7-p1-q1.html
<html>
<body>
<form action="slip7-p2-q1.php" method="get">
<h1>Enter weight in gram</h1>
<input type="text" name="cel">
<h1>Enter weight in kg</h1>
<input type="text" name="far">
<br><h1>SELECT YOUR CHOICE:<br>
<input type="radio" name=r value="1">1.Convert to kg<br>
<input type="radio" name=r value="2">2.Convert to gram<br></h1>
<input type="submit" value="calculate">
</form>
</body>
</html>
slip7-p2-q1.php
<?php
//$r=$_POST["r"];
//$h=$_POST["h"];
$cs=$_GET["cel"];
$f=$_GET["far"];
$ch=$_GET["r"];
interface kg
{
function convert_to_kg();
function convert_to_gram();
}
class Convert implements Kg
{
public $c,$f;
function __construct($cs,$f)
{
$this->c=$cs;
$this->f=$f;
}
function convert_to_kg()
{
$ans=($this->c/1000);
echo"Gram into Kilogram conversion:".$ans;
}
function convert_to_gram()
{
$ans=($this->f*1000);
echo"Kilogram into gram conversion:".$ans;
}
}
$cs=$_GET["cel"];
$f=$_GET["far"];
$ch=$_GET["r"];
$obj= new Convert($cs,$f);
if($ch==1)
{
$obj->convert_to_kg();
}
if($ch==2)
{
$obj->convert_to_gram();
}
?>
0 Comments