Idea Solution
<?php if(!isset($_GET['customer_id']) || !isset($_GET['units'])){ $customer_id = 0; $units = 0; } else{ $customer_id = $_GET['customer_id']; $units = $_GET['units']; } $amount = 0; if($units > 0 && $units <= 50) { $amount = $units * 0.50; } else if($units <= 150) { $amount = 50 * 0.5 + (($units - 50) * 0.75); } else if($units <= 250) { $amount = 50 * 0.5 + 100 * 0.75 + (($units - 150) * 1.00); } else { $amount = 50 * 0.5 + 100 * 0.75 + 100 * 1.0 + (($units - 250) * 1.50); } $tax = $amount * 0.18; $payable = $amount + $tax; $lp_surcharge = $payable * 0.05; $late_payable = $payable + $lp_surcharge; ?> <html> <head> <title>Assignment No. 2 (Solution) - Fall 2019</title> </head> <body bgcolor="#CCCCCC"> <table width="1800" border="0" align="center" cellpadding="20" cellspacing="0"> <tr> <td height="200" colspan="2" align="center" valign="middle" bgcolor="#CC6633"><h1>Natural Gas Company Pakistan</h1></td> </tr> <tr> <td width="300" align="center" valign="top" bgcolor="#FF9966"><table width="100%" border="0" cellspacing="0" cellpadding="20"> <tr> <td align="right"><strong>Customer ID</strong></td> </tr> <tr> <td align="right"><strong>Units Consumed</strong></td> </tr> <tr> <td align="right"><strong>Cost of Gas</strong></td> </tr> <tr> <td align="right"><p><strong>Taxes (18%)</strong></p></td> </tr> <tr> <td align="right"><strong>Payable within Due Date</strong></td> </tr> <tr> <td align="right"><strong>Late Payment Surcharge (5%)</strong></td> </tr> <tr> <td align="right"><strong>Payable after Due Date</strong></td> </tr> </table> </td> <td height="500" align="left" valign="top" bgcolor="#FFDECE"><table width="100%" border="0" cellspacing="0" cellpadding="20"> <tr> <td><strong><?php echo $customer_id; ?></strong> </td> </tr> <tr> <td><?php echo $units; ?></td> </tr> <tr> <td><?php echo $amount; ?></td> </tr> <tr> <td><?php echo intval($tax*100) / 100; ?></td> </tr> <tr> <td><?php echo intval($payable * 100) / 100; ?></td> </tr> <tr> <td><strong><?php echo intval($lp_surcharge * 100) / 100; ?></strong></td> </tr> <tr> <td><strong><?php echo intval($late_payable * 100) / 100; ?></strong></td> </tr> </table></td> </tr> <tr> <td height="140" colspan="2" align="center" valign="middle" bgcolor="#CC6633"><h4>Copy Rights: NGCP</h4></td> </tr> </table> </body> </html>Ideas 2
<?php if (isset($_POST[‘submit’])) { $salary = $_POST[‘salary’]; if ($salary>50000) { $insurance = (20/100)*$salary; echo “Your salary is “.$salary . ” And Calculated insurance is “. $insurance; }elseif($salary>40000){ $insurance = (15/100)*$salary; echo “Your salary is “.$salary . ” And Calculated insurance is “. $insurance; }elseif($salary>30000){ $insurance = (10/100)*$salary; echo “Your salary is “.$salary . ” And Calculated insurance is “. $insurance;