dakata450

Untitled

Jun 29th, 2022
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class rrrr {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. double money = Double.parseDouble(scanner.nextLine());
  7. int yearToLive = Integer.parseInt(scanner.nextLine());
  8. int ivancho = 19;
  9. double moneyToSpare = 0;
  10.  
  11.  
  12. for (int i = 1800; i <= yearToLive ; i++) {
  13. if(i % 2 == 0){
  14. moneyToSpare += 12000;
  15. }else{
  16. moneyToSpare += 12000 + (50 * ivancho++);
  17. }
  18.  
  19. }
  20. if(moneyToSpare < money){
  21. System.out.printf("Yes! He will live a carefree life and will have %.2f dollars left.", money - moneyToSpare);
  22. }else {
  23. System.out.printf("He will need %.2f dollars to survive.", moneyToSpare - money);
  24. }
  25.  
  26.  
  27. }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment