Advertisement
psi_mmobile

Untitled

May 23rd, 2022
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         double money = Double.parseDouble(scanner.next());
  5.         int year = scanner.nextInt();
  6.        
  7.         for (int i = 0; i <= (year - 1800); i++) {
  8.             if (i % 2 == 0) {
  9.                 money -= 12000;
  10.             } else {
  11.                 money -= (12000 + ((18+i) * 50));
  12.             }
  13.         }
  14.         if (money >= 0) {
  15.             System.out.printf("Yes! He will live a carefree life and will have %.2f dollars left.", money);
  16.         } else {
  17.             System.out.printf("He will need %.2f dollars to survive.", Math.abs(money));
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement