Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $budget = floatval(readline());
- $numOfChocolate = intval(readline());
- $quantityMilk = floatval(readline());
- $mandarin = 0.20;
- $chocolate = 0.65;
- $literMilk = 2.70;
- //$quantityMandarin = $numOfChocolate - $numOfChocolate * 0.35;
- $totalPriceChocolate = $numOfChocolate * $chocolate;
- $totalPriceMilk = $quantityMilk * $literMilk;
- $totalPriceMandarin = floor($numOfChocolate - ($numOfChocolate * 0.35)) * $mandarin;
- $total = $totalPriceChocolate + $totalPriceMilk + $totalPriceMandarin;
- $leftMoney = abs($budget-$total);
- if($total <= $budget){
- printf("You got this, %.2f money left!",$leftMoney) ;
- }else{
- printf("Not enough money, you need %.2f more!",$leftMoney) ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement