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