Question: please edit the code below to add a condition to your function . If the number of hours exceeds 40 hours then assign a 5%
please edit the code below to add a condition to your function . If the number of hours exceeds 40 hours then assign a 5% bonus to the wage, if it's between 30-40 assign 3% bonus to the wage.
function calculateWage($hours, $wage) {
$wage = $hours * $wage;
return $wage;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$hours = $_POST['hours'];
$wage = $_POST['wage'];
// call the calculateWage function to get the wage
$wage = calculateWage($hours, $wage);
// print the result message
echo "Your wage is: $" . number_format($wage, 2);
// repopulate the form fields with the input values
$hours = isset($_POST['hours']) ? htmlspecialchars($_POST['hours']) : '';
$wage = isset($_POST['wage']) ? htmlspecialchars($_POST['wage']) : '';
} else {
// set default values for the form fields
$hours = '';
$wage = '';
}
?>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
