15 points
Write a PHP program for the
following create a calculator
that can store two values and
perform operations like add,
subtract, multiplication and
divide *
image.jpg X
M
image.jpg X
Answers
Answer: YOU CAN USE THIS
<html>
<body>
<FORM ACTION="<?php $_SERVER['PHP_SELF']; ?>" method="POST">
Enter first no :<input type=text name=no1 ><br>
Enter second no :<input type=text name=no2><br>
Select Operation which u have to perform :
<select name=cal>
<option value="1">Addition</option>
<option value="2">Substraction</option>
<option value="3">Multiplication</option>
<option value="4">Division</option>
</select><br>
<input type=submit name=submit value=Calculate>
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$no1=$_POST['no1'];
$no2=$_POST['no2'];
$cal=$_POST['cal'];
if((!empty($no1)) && (!empty($no2)))
{
switch($cal)
{
case 1:$add=$no1+$no2;
echo "addition=".$add;
break;
case 2:$sub=$no1-$no2;
echo "subtraction=".$sub;
break;
case 3:$mult=$no1*$no2;
echo "multiplication=".$mult;
break;
case 4:$div=$no1/$no2;
echo "division=".$div;
break;
Answer:
<!doctype html>
<html> <head> <meta charset="utf-8"> <title>Answer</title> </head> <body> <p>The answer is: <?php if($_POST['group1'] == add) { echo "$first + $second"; } else if($_POST['group1'] == subtract) { echo "$first - $second"; } else if($_POST['group1'] == times) { echo "$first * $second"; } else($_POST['group1'] == divide) { echo "$first / $second"; } ?> </p>
</body>
</html>
hope it helps
plz mark me as the brainliest