Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. package com.company;
  2.  
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) {
  9. // write your code hereS
  10. Scanner sc = new Scanner(System.in);
  11. double neededMoney = Double.parseDouble(sc.nextLine());
  12. int countMonths = Integer.parseInt(sc.nextLine());
  13. double savedMoney = 0;
  14. for (int i = 1; i <=12 ; i++) {
  15.  
  16. if (i%2==1&&i!=1){
  17. double spentMoney = savedMoney*0.16;
  18. savedMoney=savedMoney-spentMoney;
  19. }else if (i%4==0){
  20. double bonus = savedMoney*0.25;
  21. savedMoney=savedMoney+bonus;
  22. }
  23. savedMoney=savedMoney+0.25*neededMoney;
  24. if (savedMoney>=neededMoney){
  25. break;
  26. }
  27. }
  28. if (savedMoney>=neededMoney){
  29. System.out.printf("Bravo! You can go to Disneyland and you will have %.2flv. for souvenirs.",savedMoney-neededMoney);
  30. }else{
  31. System.out.printf("Sorry. You need %.2flv. more.", neededMoney-savedMoney);
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement