PHP and HTML class ----- !!!!!!!!! A painting company has determined that for ev
ID: 3878294 • Letter: P
Question
PHP and HTML class ----- !!!!!!!!!
A painting company has determined that for every 115 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $20.00 per hour for labor. Write a program that asks the user to enter the square feet of wall space to be painted and the price of the paint per gallon in an HTML form. The program should display the following data: • The number of gallons of paint required • The hours of labor required • The cost of the paint • The labor charges • The total cost of the paint job.
Explanation / Answer
Ans.)
HTML
<html>
<head>
<title>Test</title>
</head>
<body>
<form method="get" action="calculate.php" >
<table>
<tr>
<td>Sq. Feet of Wall to be painted ?</td>
<td><input type="text" name="sqfeet" required /></td>
<td></td>
</tr>
<tr>
<td>Price of Paint Per Gallon ?</td>
<td><input type="text" name="galonPrice" required /></td>
<td><input type="submit" name="submit" value="Calculate" /></td>
</tr>
</table>
</form>
</body>
</html>
PHP:
<?php
if(isset($_GET['submit'])
{
$sqfeet=$_GET['sqfeet'];
$galonPrice=$_GET['galonPrice'];
$galonsOfPaint=(1/115)*$sqfeet;
$hoursOfWork=(8/115)*$sqfeet;
$laborCharges=$hoursOfWork*20;
$galonCharges=$galonPrice*$galonsOfPaint;
$total=$laborCharges+$galonCharges;
echo "The number of gallons of paint required : ".$galonsOfPaint;
echo "The hours of labor required : ".$hoursOfWork;
echo "The cost of the paint : ".$galonCharges;
echo "The labor charges : ".$laborCharges;
echo "The total cost of the paint job : ".$total;
}
?>
You can use WAMP or XAMPP to test this out. For any clarifications, drop a comment. Cheers.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.