Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DisneylandJourney {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double journeyCost = Double.parseDouble(scanner.nextLine());
- int numbersOfMonths = Integer.parseInt(scanner.nextLine());
- double totalMoney = 0;
- for (int i = 1; i <= numbersOfMonths; i++) {
- if (i % 2 == 1 && i != 1) {
- double spentMoney = totalMoney * 0.16;
- totalMoney -= spentMoney;
- }
- if (i % 4 == 0) {
- double bonus = totalMoney * 0.25;
- totalMoney += bonus;
- }
- double saveTheMoney = journeyCost * 0.25;
- totalMoney += saveTheMoney;
- }
- if (totalMoney >= journeyCost) {
- double moneySouvenirs = totalMoney - journeyCost;
- System.out.printf("Bravo! You can go to Disneyland and you will have %.2flv. for souvenirs.", moneySouvenirs);
- } else {
- double lostMoney = journeyCost - totalMoney;
- System.out.printf("Sorry. You need %.2flv. more.", lostMoney);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement