Advertisement
Guest User

Untitled

a guest
Feb 10th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <?php
  2.  
  3. $cash = readline();
  4. $yearstoliveto = readline();
  5. $casheven = 0;
  6. $cashodd = 0;
  7. $years = 18;
  8. for ($i = 1800; $i <= $yearstoliveto; $i++) {
  9. $years = $years++;
  10. if ($i % 2 == 0) {
  11. $casheven += 12000;
  12.  
  13. } else{
  14.  
  15. $cashodd = $cashodd + 12000 + $years * 50;
  16. }
  17. }
  18. $Diff = abs($cash - ($cashodd + $casheven));
  19. if ($cash >= $cashodd + $casheven) {
  20. printf("Yes! He will live a carefree life and will have %.2f dollars left.", $Diff);
  21. } else {
  22. printf("He will need %.2f dollars to survive.", $Diff);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement