Advertisement
Guest User

Untitled

a guest
Feb 10th, 2018
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. <?php
  2.  
  3. $cash = readline();
  4. $yearsToLive = readline();
  5. $years = 18;
  6.  
  7. for ($i = 1800; $i <= $yearsToLive; $i++) {
  8.     if ($i % 2 === 0) {
  9.         $cash -= 12000;
  10.     } else {
  11.         $cash -= 12000 + $years * 50;
  12.     }
  13.  
  14.     $years++;
  15. }
  16.  
  17. $diff = abs($cash);
  18.  
  19. if ($cash >= 0) {
  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. }
  24.  
  25. //DvDty
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement