Quick
Saturday, 31 December 2011
Thursday, 15 December 2011
electricity bill program in php
Write a program to calculate the electricity bill. The rates
of electricity per units are as follow:
If the units consumed are equal or less than 300, then the
cost is Rs.3/-per unit.
If units consumed are more than 300, then the cost is Rs.
3.5/- per unit and a surcharge of 5% of bill is added.
Create a HTML file with name ( Bill.HTML ) create a form
like this
<form action="data.php"
method="post">
Enter current reading: <br/><input
type="text" name="cu"/><br/>
Enter previous reading :<br/><input type="text"
name="pu"/><br/>
<input type="submit" name="submit"
value="submit"/>
</form>
Create another file with name (data.php) write a code
<?php
$cu = $_POST['cu'];
$pu = $_POST['pu'];
$units=$cu-$pu;
if ($units>300)
$bill=$units*3.5
+ $units*0.05/100;
if ($units<=300)
$bill=$units*3.0;
{
echo
“Electricity Bill: ".$bill;
}
?>