Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DemoForBackToThePast {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double money = Double.parseDouble(scanner.nextLine());
- int endYear = Integer.parseInt(scanner.nextLine());
- int countEvevnYear = 0;
- int countOddYear = 0;
- int ivanchoYear = 17;
- for (int i = 1800; i <= endYear; i++) {
- ivanchoYear++;
- if (i % 2 != 0) {
- countOddYear += 12000 + (ivanchoYear * 50);
- } else {
- countEvevnYear += +12000;
- }
- }
- int expense = countEvevnYear + countOddYear;
- if (money > expense) {
- System.out.printf("Yes! He will live a carefree life and will have %.2f dollars left.", money - expense);
- } else {
- System.out.printf("He will need %.2f dollars to survive.", expense - money);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement