Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2020
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function inherit(input) {
  2.     let money = Number(input.shift());
  3.     let year = Number(input.shift());
  4.     let age = 18;
  5.     for (i = 1800; i <= year; i++) {
  6.         if (i % 2 == 0) {
  7.             money -= 12000;
  8.             age += 1;
  9.         } else {
  10.             money -= 12000 + age * 50;
  11.             age += 1;
  12.         }
  13.     }
  14.     if (money >= 0) {
  15.         console.log(`Yes! He will live a carefree life and will have ${money.toFixed(2)} dollars left.`);
  16.     } else {
  17.         console.log(`He will need ${Math.abs(money.toFixed(2))} dollars to survive.`);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement