Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PHP/HTML. Can someone help me with this: (below is my code when I go to the loca

ID: 3671884 • Letter: P

Question

PHP/HTML. Can someone help me with this: (below is my code when I go to the localhost and run it, nothing displays. Also, is there an easier loop to use than this?)

Write a program that calculated an employee's net pay. The user should enter Hourly pay rate, Number of hours worked in a week, Number of dependents claimed. If the employee works more than 45 hours in a week, overtime is calculated at 1.5 times the regular hourly rate. Taxes are then deducted from the gross pay as follows: No dependents: tax rate is 25%, 1 to 3 dependents: tax rate is 20%, 4 to 6 dependents: tax rate is 10%, More than 6 dependents: tax rate is 5%.

Input test case one:

Employee's hourly rate: $30. Number of hours worked this week: 50 hours. Number of dependents: 3.

Output test case 1 and logic:

First 45 hours pay = $30 x 45 hours = $1350. Next 5 hours pay (overtime) = $30 x 5 hours x 1.5 = $225. Gross pay = $1350 + $225 = $1575. Tax rate for 3 dependents = 20%. Tax deduction = $1575 x 20% = $315. Net pay = $1575 - $315 = $1260. This employee earned: $1260 this week.

Any help would be appreciated, thank you.

My code:(PHP)

<!DOCTYPE html>
<!--
Course: CSCI 4000
Author: Mikayla Webber
Program: Due February 22, 2016
-->
<?php
   $hourlyRate = $_POST['hourlyRate'];
   $hoursWorked = $_POST['hoursWorked'];
   $dependents = $_POST['dependents'];
   $hoursWorked_escaped = htmlspecialchars($hoursWorked);
   $hourlyRate_escaped = htmlspecialchars($hourlyRate);
   $dependents_escaped = htmlspecialchars($dependents);
?>
<html lang="en">

<head> <!-- open of head -->
          
       <meta charset="utf-8">
       <title> Mikayla Webber's Employee Net Pay </title> <!-- title of webpage -->
       <link rel="stylesheet" href="style.css"> <!-- connects to style sheet -->
      
   </head>
  
   <body> <!-- beginning of the body section -->
  
       <header>
      
           <h1> Mikayla Webber's Employee Net <br>Pay </h1>
          
       </header>
      
       <!-- paragraph and list on webpage -->
       <p><br> This page calculates an employer's net pay. </p><br>
      
       <h2>You entered:</h2><br>
      
       <!-- php to calcuate the employee net pay -->
      
       <?php          
           {
               if ($dependents = 0)
               {
                   $taxRate = 25;
                   $calculateTaxRate = 0.25;
                   $overtimeHours = (hoursWorked - 45);
                   $firstFourtyFive = ($hourlyRate * 45);
                   $overtime = ($hourlyRate * $overtimeHours * 1.5);
                   $grossPay = ($firstFourtyFive + $overtime);
                   $tax = ($grossPay * $calculateTaxRate);
                   $taxDeduction = ($tax + $grossPay);
                   $netPay = ($grossPay - $taxDeduction);
                   echo "Employee's hourly rate of pay = $". "<b>". $hourlyRate. "</b>". " per hour". "<br> ";
                   echo "Number of hours worked that week = ". "<b>". $hoursWorked. "</b>". " hours". "<br> ";
                   echo "Number of dependents employee has = ". "<b>". $dependents. "</b>". " dependents". "<br> ";
                   echo "Number of overtime hours = ". "<b>". $hoursWorked. " - 45 = ". $overtimeHours. "</b>". " hours". "<br> ";
                   echo "First 45 hours pay = ". "<b>". "$". $hourlyRate. " x 45 = $". $firstFourtyFive. "</b>". "<br> ";
                   echo "Next ". $overtimeHours. " hours pay (overtime) = ". "<b>". "$". $hourlyRate. " x ". $overtimeHours. " x 1.5 = $". $overtime. "</b>". "<br> ";
                   echo "Gross pay = ". "<b>". "$". $firstFourtyFive. " + ". "$". $overtime. " = $". $grossPay. "</b>". "<br> ";
                   echo "Tax rate for ". "<b>". $dependents. "</b>". " dependents = ". "<b>". $taxRate. "</b>". "<br> ";
                   echo "Tax deduction = ". "<b>". $grossPay. " x ". $taxRate. "% = $". $taxDeduction. "</b>". "<br> ";
                   echo "Net pay = ". "<b>". "$". $grossPay. " - $". $taxDeduction. " = $". $netPay. "</b><br> ";
                   echo "This employee earned: <b>". $netPay. "</b> this week.". "<br> ";
               }
               else if ($dependents >= 1 && $dependents <= 3)
               {
                   $taxRate = 20;
                   $calculateTaxRate = 0.20;
                   $overtimeHours = (hoursWorked - 45);
                   $firstFourtyFive = ($hourlyRate * 45);
                   $overtime = ($hourlyRate * $overtimeHours * 1.5);
                   $grossPay = ($firstFourtyFive + $overtime);
                   $tax = ($grossPay * $calculateTaxRate);
                   $taxDeduction = ($tax + $grossPay);
                   $netPay = ($grossPay - $taxDeduction);
                   echo "Employee's hourly rate of pay = $". "<b>". $hourlyRate. "</b>". " per hour". "<br> ";
                   echo "Number of hours worked that week = ". "<b>". $hoursWorked. "</b>". " hours". "<br> ";
                   echo "Number of dependents employee has = ". "<b>". $dependents. "</b>". " dependents". "<br> ";
                   echo "Number of overtime hours = ". "<b>". $hoursWorked. " - 45 = ". $overtimeHours. "</b>". " hours". "<br> ";
                   echo "First 45 hours pay = ". "<b>". "$". $hourlyRate. " x 45 = $". $firstFourtyFive. "</b>". "<br> ";
                   echo "Next ". $overtimeHours. " hours pay (overtime) = ". "<b>". "$". $hourlyRate. " x ". $overtimeHours. " x 1.5 = $". $overtime. "</b>". "<br> ";
                   echo "Gross pay = ". "<b>". "$". $firstFourtyFive. " + ". "$". $overtime. " = $". $grossPay. "</b>". "<br> ";
                   echo "Tax rate for ". "<b>". $dependents. "</b>". " dependents = ". "<b>". $taxRate. "</b>". "<br> ";
                   echo "Tax deduction = ". "<b>". $grossPay. " x ". $taxRate. "% = $". $taxDeduction. "</b>". "<br> ";
                   echo "Net pay = ". "<b>". "$". $grossPay. " - $". $taxDeduction. " = $". $netPay. "</b><br> ";
                   echo "This employee earned: <b>". $netPay. "</b> this week.". "<br> ";
               }
               else if ($dependents >= 4 && $dependents <= 6)
               {
                   $taxRate = 10;
                   $calculateTaxRate = 0.10;
                   $overtimeHours = (hoursWorked - 45);
                   $firstFourtyFive = ($hourlyRate * 45);
                   $overtime = ($hourlyRate * $overtimeHours * 1.5);
                   $grossPay = ($firstFourtyFive + $overtime);
                   $tax = ($grossPay * $calculateTaxRate);
                   $taxDeduction = ($tax + $grossPay);
                   $netPay = ($grossPay - $taxDeduction);
                   echo "Employee's hourly rate of pay = $". "<b>". $hourlyRate. "</b>". " per hour". "<br> ";
                   echo "Number of hours worked that week = ". "<b>". $hoursWorked. "</b>". " hours". "<br> ";
                   echo "Number of dependents employee has = ". "<b>". $dependents. "</b>". " dependents". "<br> ";
                   echo "Number of overtime hours = ". "<b>". $hoursWorked. " - 45 = ". $overtimeHours. "</b>". " hours". "<br> ";
                   echo "First 45 hours pay = ". "<b>". "$". $hourlyRate. " x 45 = $". $firstFourtyFive. "</b>". "<br> ";
                   echo "Next ". $overtimeHours. " hours pay (overtime) = ". "<b>". "$". $hourlyRate. " x ". $overtimeHours. " x 1.5 = $". $overtime. "</b>". "<br> ";
                   echo "Gross pay = ". "<b>". "$". $firstFourtyFive. " + ". "$". $overtime. " = $". $grossPay. "</b>". "<br> ";
                   echo "Tax rate for ". "<b>". $dependents. "</b>". " dependents = ". "<b>". $taxRate. "</b>". "<br> ";
                   echo "Tax deduction = ". "<b>". $grossPay. " x ". $taxRate. "% = $". $taxDeduction. "</b>". "<br> ";
                   echo "Net pay = ". "<b>". "$". $grossPay. " - $". $taxDeduction. " = $". $netPay. "</b><br> ";
                   echo "This employee earned: <b>". $netPay. "</b> this week.". "<br> ";
               }
               else if ($dependents > 6)
               {
                   $taxRate = 5;
                   $calculateTaxRate = 0.05;
                   $overtimeHours = (hoursWorked - 45);
                   $firstFourtyFive = ($hourlyRate * 45);
                   $overtime = ($hourlyRate * $overtimeHours * 1.5);
                   $grossPay = ($firstFourtyFive + $overtime);
                   $tax = ($grossPay * $calculateTaxRate);
                   $taxDeduction = ($tax + $grossPay);
                   $netPay = ($grossPay - $taxDeduction);
                   echo "Employee's hourly rate of pay = $". "<b>". $hourlyRate. "</b>". " per hour". "<br> ";
                   echo "Number of hours worked that week = ". "<b>". $hoursWorked. "</b>". " hours". "<br> ";
                   echo "Number of dependents employee has = ". "<b>". $dependents. "</b>". " dependents". "<br> ";
                   echo "Number of overtime hours = ". "<b>". $hoursWorked. " - 45 = ". $overtimeHours. "</b>". " hours". "<br> ";
                   echo "First 45 hours pay = ". "<b>". "$". $hourlyRate. " x 45 = $". $firstFourtyFive. "</b>". "<br> ";
                   echo "Next ". $overtimeHours. " hours pay (overtime) = ". "<b>". "$". $hourlyRate. " x ". $overtimeHours. " x 1.5 = $". $overtime. "</b>". "<br> ";
                   echo "Gross pay = ". "<b>". "$". $firstFourtyFive. " + ". "$". $overtime. " = $". $grossPay. "</b>". "<br> ";
                   echo "Tax rate for ". "<b>". $dependents. "</b>". " dependents = ". "<b>". $taxRate. "</b>". "<br> ";
                   echo "Tax deduction = ". "<b>". $grossPay. " x ". $taxRate. "% = $". $taxDeduction. "</b>". "<br> ";
                   echo "Net pay = ". "<b>". "$". $grossPay. " - $". $taxDeduction. " = $". $netPay. "</b><br> ";
                   echo "This employee earned: <b>". $netPay. "</b> this week.". "<br> ";
               }
           }
       ?>
       <br><br>
      
       <!-- below is to display the back to previous page button -->
       &emsp;&emsp;<a href="index.php">back to first page</a>
       <br><br>
   </body>
</html>

Explanation / Answer

Hi below i written a sample PHP/HTML code for your reference on calculating earnings based on wage, hours, and potential overtime over 40 hours at 1.5. for your reference,

paycheck.php

<head>