Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

University of Makati

College of Computer Science

Web System and Technologies

Seat Work: 2

1
1. Create a PHP script that would input three numbers and display the sum, difference, quotients,
product, and modulus.

Give the following:

A. Code

<html>
<body
<form method="post">
Enter 1st Number:
<input type="n" name="n1" /><br><br>
Enter 2nd Number:
<input type="n" name="n2" /><br><br>
Enter 3rd Number:
<input type="n" name="n3" /><br><br>
<input type="submit" name="submit" value="Compute">

</form>
<?php
if(isset($_POST['submit']))
{
$num1 = $_POST['n1'];
$num2 = $_POST['n2'];
$num3 = $_POST['n3'];

$sum = $num1+$num2+$num3;
$difference = $num1-$num2-$num3;
$quotient = $num1/$num2/$num3;
$product = $num1*$num2*$num3;
$modulus = $num1%$num2%$num3;

echo "The sum of $num1 and $num2 and $num3 is: ".$sum;
echo "<br>";
echo "The difference of $num1 and $num2 and $num3 is: ".$difference;
echo "<br>";
echo "The quotient of $num1 and $num2 and $num3 is: ".$quotient;
echo "<br>";
echo "The product of $num1 and $num2 and $num3 is: ".$product;
echo "<br>";
echo "The modulus of $num1 and $num2 and $num3 is: ".$modulus;
}
?>
</body>
</html>

2
B. Output

3
4

You might also like