Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- // write your code hereS
- Scanner sc = new Scanner(System.in);
- double neededMoney = Double.parseDouble(sc.nextLine());
- int countMonths = Integer.parseInt(sc.nextLine());
- double savedMoney = 0;
- for (int i = 1; i <=12 ; i++) {
- if (i%2==1&&i!=1){
- double spentMoney = savedMoney*0.16;
- savedMoney=savedMoney-spentMoney;
- }else if (i%4==0){
- double bonus = savedMoney*0.25;
- savedMoney=savedMoney+bonus;
- }
- savedMoney=savedMoney+0.25*neededMoney;
- if (savedMoney>=neededMoney){
- break;
- }
- }
- if (savedMoney>=neededMoney){
- System.out.printf("Bravo! You can go to Disneyland and you will have %.2flv. for souvenirs.",savedMoney-neededMoney);
- }else{
- System.out.printf("Sorry. You need %.2flv. more.", neededMoney-savedMoney);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement