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