-5
I have the following statement:
A parking lot charges a minimum fee of R$2.00 to park by three hours. An additional R$0.50 per hour does not necessarily is charged after the first three hours. The maximum amount for any given 24-hour period is $10.00. Suppose no car is parked for more than 24 hours at a time. Write an app which calculates and displays the parking fees for each customer who parked in this garage yesterday. You must enter the hours of parking for each customer. The program must display the charge for the current customer and calculate and display the total received at the end of the day. The program must use a pathValue function to determine the charge for each customer.
That’s what I tried to do:
<?php
if ($_POST) {
$t = $_POST['num-hor'];
$total = valorApagar($t);
echo"<br><br>Total: R$".number_format($total, 2, ',', '.');
}
function valorApagar($t){
$total = 0;
if ($t <= 3) {
$total = 2;
}else if ($t > 3 && $t < 24) {
$total = 2;
$t -= 3;
if(is_int($t) == true){
$total += $t;
}else{
$t = ceil($t);
$t *= 0.5;
$total += $t;
}
}else {
$total = 10;
}
return $total;
}
?>
The function valorApagar()
is not returning me the correct result, how to adjust it to return the result according to what is requested in the statement?
What’s the matter?
– rray