Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $cash = readline();
- $yearstoliveto = readline();
- $casheven = 0;
- $cashodd = 0;
- $years = 18;
- for ($i = 1800; $i <= $yearstoliveto; $i++) {
- $years = $years++;
- if ($i % 2 == 0) {
- $casheven += 12000;
- } else{
- $cashodd = $cashodd + 12000 + $years * 50;
- }
- }
- $Diff = abs($cash - ($cashodd + $casheven));
- if ($cash >= $cashodd + $casheven) {
- printf("Yes! He will live a carefree life and will have %.2f dollars left.", $Diff);
- } else {
- printf("He will need %.2f dollars to survive.", $Diff);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement