Jump to content

Simple math problem


zimbabweo

Recommended Posts

A simple math problem, but I can't get it working. If I enter 50 for $hours and 10 for $hourly I keep getting 400 $weekPay. It refuses to calculate OT pay. I don't understand what's wrong.

 

<?php

$name = $_POST['employeeName'];

$hours = $_POST['hoursWorked'];

$hourly = $_POST['hourlyPay'];

 

echo "<p>Week pay for $name \n</p>";

echo "<p>Hours worked: $hours \n</p>";

echo "<p>Pay rate: $hourly \n</p>";

 

if ($hours > 40)

{

$otHours = $hours - 40;

echo "<p>OT Hours: $otHours\n</p>";

$weekPay = (($hourly * 40) + (1.5 * hourly) * otHours);

}

else

$weekPay = $hours * $hourly;

 

echo "<p>Week pay: $weekPay </p>";

?>

Link to comment
https://forums.phpfreaks.com/topic/274901-simple-math-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.