Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BackToThePast {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double heritage = Double.parseDouble(scanner.nextLine());
- int ageToLiveIn = Integer.parseInt(scanner.nextLine());
- double moneyLeft = 0;
- int yearsCount = 18;
- for (int i = 1800; i <= ageToLiveIn ; i++) {
- if (i % 2 == 0) {
- heritage -= 12000;
- }else {
- heritage -= 12000 + (yearsCount * 50);
- }
- yearsCount++;
- }
- 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