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.   "> Number of Hours Worked: Hourly Wage:

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question
100%

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.

<?php

 

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 = '';

}

 

?>

 

<form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">

<label for="hours">Number of Hours Worked:</label>

<input type="text" name="hours" value="<?php echo $hours; ?>"><br><br>

<label for="wage">Hourly Wage:</label>

<input type="text" name="wage" value="<?php echo $wage; ?>"><br><br>

<input type="submit" value="Calculate">

</form>

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Data Binding
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning