Професионална програма
+ Нов въпрос
TheShu avatar TheShu 1 Точки

Java disneyland journey - Mid Exam

import java.util.Scanner;

public class Exam {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int savedMoney = 0;
        int months = 1;
        double journeyMoney = Double.parseDouble(scan.nextLine());
        double numberOfMonths = Double.parseDouble(scan.nextLine());
        while(months <= numberOfMonths){
            if (months % 4 == 0){
                savedMoney += savedMoney * 0.25;
            savedMoney += journeyMoney * 0.25;
        if (savedMoney >= journeyMoney){
            double money = (savedMoney - journeyMoney);
            System.out.printf("Bravo! You can go to Disneyland and you will have %.2f lv. for souvenirs.", money);
        }else {
            double money = (journeyMoney - savedMoney);
            System.out.printf("Sorry. You need %.2f lv. more.",money);


// Create a program that checks if you can save the money for Disneyland's journey. // you have a certain number of months for which you can collect the money. // At the end of each month, you save 25% of the cost of the journey. // At the beginning of every odd month (except the first one) you spent 16% of the money collected so far for clothes and shoes. // Every 4th month at the beginning of the month your boss gives you a bonus. Its 25% of the money collected so far. // If you save enough money for the journey, calculate how much money will be left for the souvenirs. Then print the following: //"Bravo! you can go to Disneyland and you will have {money}lv. for souvenirs." // if the saved money is less you should calculate how much money you need more. Then print the following: //"Sorry. You need{money}lv. more." //both numbers should be formatted to the 2nd decimal place.

Fundamentals Module
TheShu avatar TheShu 1 Точки

Не разбирам къде ми е грешката в условието Input се иска 87.50 лв, на мен ми дава 187.00 лв