In: Computer Science
Create a two-part form that calculates weekly income for Happy Diner's waitress Tammy, based on her regular hours, overtime pay, and tips. She makes $10 an hour, if she works 40 hours a week, or less. Her overtime pay is $15 an hour. If Tammy worked over 40 hours, she is earning her overtime wages. Happy customers give her tips as well.
Use an HTML document named tipsYourlastname.html as a Web form with two text boxes — one for the number of hours worked and one for the tips. Use a PHP document named tipsyourlastname.php as the form handler. Output the total amount earned to the screen in some nice organized manner. Please comment your code appropriately and test your program with various input to ensure it operates correctly. Check your math as well.
Please remember that program has to work to get credit. This is a very small program, but you need to plan ahead and give yourself enough time for testing and debugging. Write a small piece of code at a time and test it before you add more code. Work incrementally.
PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU
//tipsYourlastname.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hours Worked + Tips</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1> Check Caluclations </h1>
<!-- Displaying the form that takes the number
of hours worked and tips recieved!-->
<form action= "tips.php" method= "get">
<p> Enter the number of hours worked</p>
<!-- input for the hours worked!-->
<input type="text" name="hours"/>
<p> Enter the amount of tips</p>
<!-- Input for tips made!-->
<input type= "text" name= "tips"/>
<p> <input type= "submit"/> </p>
</form>
</body>
</html>
//tipsyourlastname.php
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title> Check Results </title>
</head>
<body>
<h1> Check Results </h1>
<?php
//* using GET parameter to get the hours worked,tips and over time *//
$Hours =$_GET["hours"];
$Tips = $_GET["tips"];
$OverTime = $Hours-40;//deducting 40 from $Hours as it gives us the overtime.
// checking if the user input is valid if not Hours/Overtime equals to zero *//
if(is_numeric($Hours) && is_numeric($Tips)){
// checking if the user worked more than fourty hours*//
if ($Hours<=40)
{
// calculating if the hours and tips below fourty hours & storing it into a variable*//
$PayCheck = $Hours*10 + $Tips;// paycheck will be evaluated result of hours worked * 10 + tips
echo "<p> Amoumt pay: ".$PayCheck."</p>";
}
// If the hours are greater than fourty *//
if ($Hours > 40 )
{
//paycheck in this case will be the evaluation of addition of (hours worked - overtime * 10), (overtime*15) and tips
$PayCheck = (10 * ($Hours-$OverTime))+($OverTime*15) + $Tips;
echo "<p> Amount pay with over time is ".$PayCheck."</p> ";
}
}
else
{
//Invalid input of number of hours worked & over time *//
echo "Invalid input Numbers!";
}
?>
</body>
</html>