https://www.codecademy.com/courses/learn-php/projects/world-traveler
Hello, I am struggling with step 6 of this PHP project to remove the extra decimals from the currency conversion; specifically, the step mentions the possibility of using (%) modulo to do so and an example is shown but I am struggling to apply the concept to my code in the console to reflect change in the interface (both below). Would someone be able to take a look at what I’ve done below and perhaps show one example of removing the excess digits, so that I can work that solution through the rest of the code? Hope that makes sense?
Begin:
<?php $riel = 2103942; $kyat = 19092; $krones = 109; $lek = 9094; echo "At the start of your transaction you had ${riel} riel, ${kyat} kyat, ${krones} krones, and ${lek} lek."; $riel_to_GBP = 0.00018; $kyat_to_GBP = 0.00051; $krones_to_GBP = 11.75; $lek_to_GBP = 0.0069; $GBP_from_riel = $riel * $riel_to_GBP; $GBP_from_kyat = $kyat * $kyat_to_GBP; $GBP_from_krones = $krones * $krones_to_GBP; $GBP_from_lek = $lek * $lek_to_GBP; echo "\n"; echo "\nYour $riel riel were exchanged for $GBP_from_riel GBP."; echo "\n"; echo "\nYour $kyat kyat were exchanged for $GBP_from_kyat GBP."; echo "\n"; echo "\nYour $krones krones were exchanged for $GBP_from_krones GBP."; echo "\n"; echo "\nYour $lek lek were exchanged for $GBP_from_lek GBP."; echo "\n"; $final_amount = $GBP_from_riel += $GBP_from_kyat += $GBP_from_krones += $GBP_from_lek - 1; echo "\n"; echo "At the end of the transaction, with a £1 conversion fee deduction, you have $final_amount GBP."; Produces: At the start of your transaction you had 2103942 riel, 19092 kyat, 109 krones, and 9094 lek. Your 2103942 riel were exchanged for 378.70956 GBP. Your 19092 kyat were exchanged for 9.73692 GBP. Your 109 krones were exchanged for 1280.75 GBP. Your 9094 lek were exchanged for 62.7486 GBP. At the end of the transaction, with a £1 conversion fee deduction, you have 1730.94508 GBP.