Slip no. 4. Write a PHP program to create a Class calculator which will accept two value from user and pass as an argument through parameterized constructor and do the following task.
a) Add Them
b) Subtract Them
c) Multiply them together or divide them on request.

HTML file :
<form action="slip4_Q2.php" method=get>
<tr><td>Enter No1</td><td><input type="text" name="a"></td></tr>
<tr><td>Enter No2</td><td><input type="text" name="b"></td></tr>
<tr><td></td><td><input type="submit" value="SUBMIT"></td></tr>

PHP file :
                class Calculate
                                 public $a;
                                public $b;
                                 function __construct($a,$b)
                                public function add()
                                                echo"Addition = $c<br>";
                                public function subtract()
                                                 echo"Subtract = $c<br>";
                                public function multiply()
                                                echo"Multiplication = $c<br>";
                                public function div()
                                                echo"Division = $c";
$calc=new Calculate($x,$y);

No comments:

Post a comment

Note: only a member of this blog may post a comment.