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