Advertisement
Guest User

Untitled

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