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