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