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

Modify fuelCost.php to receieve this input in addition to the other inputs. The

ID: 3599488 • Letter: M

Question

Modify fuelCost.php to receieve this input in addition to the other inputs. The program should calculate the fuel cost in the same way as before, but should then use an IF...ELSE structure to test whether or not the trip is work related. If the trip IS work related, the program should calculate the amount that will be reimbursef to you by your employer, at the rate of .35 * 100 or $35.00. IF the trip is not work related, then amount to be reimbrused will be 0.

Your program should then display the miles traveled, the fuel cost, whether or not the trip was work-related, and the amount to be reimbursed.

Explanation / Answer

<?php
      
        $mpg = $_POST['mpg'];
        $miles = $_POST['miles'];
        $costPerGallon = $_POST['costPerGallon'];
        $workRelated = $_POST['workRelated']; // Assuming 1 for work related and 0 for not work related
      
        $reimbursed = 0;
      
        if ($workRelated == 1)
        {
                  $reimbursed = 35 * $miles ; //If work related then amount would be reimbursed else not

                 // we can also reimburse the trip cost based on the logic.
        }
      
        $tripCost = ($miles/$mpg) * $costPerGallon;
                      
        print ("<p>Total miles traveled: $miles</p>");    
        print ("<p>Fuel cost: $".number_format($tripCost,2)."</p>");
        print ("<p>Work-Related: $workRelated</p>");
        print ("<p>Reimbursement Amount: $reimbursed</p>");
      
?>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote