13. PHP Program to Calculate Gain for milk vendor.
How does this program work?
- In this program you will learn about how to find gain for milk vendor using PHP.
- This program to calculate gain of a milk vendor when adds 1 litere of water for every 4 literes of milk.
- By using given formula we can get the gain of the milk vendor.
Here is the code
<html>
<head>
<title>PHP Program To calculate the gain for milk vendor</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="liters" value="" placeholder="Enter How Many Liters Milk vendor Buy"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/> </td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$milk_buy = $_POST['liters'];
if($milk_buy>=4 || $milk_buy%4==0)
{
$Water_add = $milk_buy + 1;
}
$buy_cost = $milk_buy * 3.25;
$sale_cost = $Water_add * 4.15;
$gain = $sale_cost - $buy_cost;
echo "Milk = ".$milk_buy."liters";
echo"Gain of Milk Vendor : ".$gain ." Rupees";
return 0;
}
?>
</body>
</html>