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