Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

Breyanova91 avatar Breyanova91 9 Точки

Disneyland Journey Programming Fundamentals Mid Exam Retake - 10 December 2019

Здравейте колеги,

не разбирам къде греша в тази задача - във vs си работи всичко - може ли малко помощ?

function solve(arg1arg2) {

    let savedMoney = 0;

    let months = 1;

    let journeyMoney = Number(arg1);

    let numberOfmonths = Number(arg2);

 

    while(months <= numberOfmonths){

        if(months % 2 !== 0 && months !== 1){

            savedMoney -= savedMoney * 0.16;

        }

        if(months % 4 == 0){

            savedMoney += savedMoney * 0.25;

        }

        savedMoney += journeyMoney * 0.25;

 

        months++;

    }

    if(savedMoney >= journeyMoney){

        let money = (savedMoney - journeyMoney).toFixed(2);

        console.log(`Bravo! You can go to Disneyland and you will have ${money}lv. for souvenirs.`);

    }

    else{

        let money = (journeyMoney - savedMoney).toFixed(2);

        console.log(`Sorry. You need ${money}lv. more.`);

        

    }

   

}

solve(5000,

     1)

    ;

 

Create a program that checks if you can save the money for the 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 (fourth) month at the beginning of the month your boss gives you а bonus. It is 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.

Input

  • On the 1st line you will receive how much the journey will cost – a real number in the range [500.0…10000.0]
  • On the 2nd line you will receive the number of months for which you have to collect money – an integer number in the range [1…12]

Output

  • Print the output in the format described above.

Examples

Input

Output

1000
4

Bravo! You can go to Disneyland and you will have 87.50lv. for souvenirs.

Comments

You need 1000 leva for the journey and you have 4 months to collect them. Every month you can save 1000 * 25% => 250 lv. So, to the end of the 1st month you have 250 lv. To the end of the 2nd month -  250 + 250 -> 500 lv. To the begging of the 3th month (odd month) you spent 80 lv. (500 * 16%) for clothes and shoes, then you save 250 lv, so now you have 670 lv. Last month is the fourth month and you save 670 + 167.5 (670 * 25%) + 25 = 1087.5 lv. You have 1087.5 – 1000 = 87.5 lv., so you can go to the trip.

 

3265

3

Sorry. You need 1077.45lv. more.

Тагове:
0
JavaScript Fundamentals
krasizorbov avatar krasizorbov 548 Точки

То всичко ти е вярно освен входните данни:

function solve(input) {

    let savedMoney = 0;
    let months = 1;
    let journeyMoney = Number(input.shift());
    let numberOfmonths = Number(input.shift());

    while(months <= numberOfmonths){
        if(months % 2 !== 0 && months !== 1){
           savedMoney -= savedMoney * 0.16;
        }

        if(months % 4 == 0){
            savedMoney += savedMoney * 0.25;
        }
        savedMoney += journeyMoney * 0.25;
        months++;
    }

    if(savedMoney >= journeyMoney){
        let money = (savedMoney - journeyMoney).toFixed(2);
        console.log(`Bravo! You can go to Disneyland and you will have ${money}lv. for souvenirs.`);
    }
    else{
        let money = (journeyMoney - savedMoney).toFixed(2);
        console.log(`Sorry. You need ${money}lv. more.`);        
    }
}

0
Breyanova91 avatar Breyanova91 9 Точки

добре. ок. обаче как този вход на данни да работи във vs и в judge ? и изобщо това в коя лекция го обясняват ? не мога да го разбера

0
krasizorbov avatar krasizorbov 548 Точки

Ако не знаеш как подават входните данни което се случва с всеки в javascript, правиш следното.

Отваряш judge където ти е задачата и пишеш console.log натискаш бутона submit за да изпратиш заявката

после натискаш кръглото бутонче за да се оцени и ще ти даде 0/100.

Отиваш на детайли и в дясната част където пише "Your output" в зелено ще видиш под каква форма подават входните данни!

И това е то относно проблема с входните данни в javascript

0
20/10/2020 11:56:42
CvetanSavov avatar CvetanSavov 0 Точки

Някой да има за java basic? 

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.