Loading...

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

yolowski avatar yolowski 0 Точки

Spring Vacation Trip

Spring Vacation Trip

A group of friends decide to go to a trip for a few days during spring vacation. They have a certain budget. Your task is to calculate their expenses during the trip and find out if they are going to have enough money to finish the vacation.

Create a program that calculates travelling expenses by entering the following information:

  • Days of the vacation
  • Budget - its for the whole group
  • The count of people
  • Fuel per kilometer – the price for fuel that their car consumes per kilometer
  • Food expenses per person
  • Hotel room price for one night – again, for one person

If the group is bigger than 10, they receive a 25% discount from the total hotel expenses.

Every day, they travel some distance and you have to calculate the expenses for the travelled kilometers.

Every third and fifth day, they have some additional expenses, which are 40% of the current value of the expenses.

Every seventh day, their expenses are reduced, because they withdraw (receive) a small amount of money – you can calculate it by dividing the amount of the current expenses by the group of people.

If the expenses exceed the budget at some point, stop calculating and print the following message:

"Not enough money to continue the trip"

If the budget is enough:

"You have reached the destination. You have {money}$ budget left."

Print the result formatted 2 digits after the decimal separator.

Input / Constraints

  • On the 1st line, you are going to receive the days of the trip – an integer in the range [1…100]
  • On the 2nd line – the budget – a real number in the range [0.00 – 1000000.00]
  • On the 3rd line - the group of people – an integer in the rang [1 - 50]
  • On the 4th line – the price for fuel per kilometer – a real number [0.00 – 20.00]
  • On the 5th line – food expenses per person for a day – a real number [0.00 – 50.00]
  • On the 6th line – the price for a room for one night per person – a real number [0.00 – 1000.00]
  • On the next n lines – one for each of the days – the travelled distance in kilometers per day– a real number in the range [0.00 - 1000]

Output

  • "Not enough money to continue the trip. You need {money}$ more." –
    if the budget is not enough
  • "You have reached the destination. You have {money}$ budget left." – if it’s enough.

Print the result formatted 2 digits after the decimal separator.

Examples

Input

Output

Comments

7

12000

5

1.5

10

20

512

318

202

154

222

108

123

You have reached the destination. You have 5083.48$ budget left.

We receive the days of the vacation, the budget, the group, the consumed fuel per kilometer, the food expenses and the price for a hotel room for one night. We must calclate the food expenses: 10 * 5 * 7 = 350

And the price for the hotel for all of the nights:

20 * 5 * 7 = 700

The curent expenses are 1050. For each day, we have to calculate the consumed fuel – {travelledDistance} * 1.5

On every 3rd  and 5th  day we add the additional expenses:

0.4 * {currentExpenses}

On every 7th day, they receive some money:

{currentExpense} / {groupOfPeople}

After we have added the fuel expenses for each day and made the other calculations, the expenses have reached 8645.652. When we divide them by the group (5), the result is 1729.1304, so we have to reduce the expenses by that sum. The expenses become 6916.5216. The budget is enough, so the result is:

"You have reached the destination. You have 5083.48$ budget left."

10

20500

11

1.2

8

13

100

150

500

400

600

130

300

350

200

300

Not enough money to continue the trip. You need 465.79$ more.

 

 

Здравейте, дали може някой да ми погледне решението и да ми каже къде греша , защото judge ми дава 77/100.

https://pastebin.com/F9B7BzbR

Тагове:
0
Fundamentals Module
abetterman avatar abetterman 21 Точки

Едната грешка е в това Every third and fifth day. Думата е and. Условието ти трябва да се промени вместо два if-a на един, защото с два if-a в дни които се делят и на 3 и на 5 ( като 15ти ден ) ще увеличиш цената два пъти, а трябва да е само 1 път :

if (day % 3 == 0 || day % 5 == 0) {
    totalPrice += totalPrice * 0.4;
}


Другата грешка е в този else:
 

else{
System.out.println("Not enough money to continue the trip");
return;
}

Странно е , че ако го изтриеш ще ти мине и втория тест. 
Мисля, че става объркване в задачата в този ред : 

If the expenses exceed the budget at some point, stop calculating and print the following message:

"Not enough money to continue the trip"


Но ако видиш накрая какво ти искат в Output ще забележиш, че има само два варианта, а не три : 
 

  • "Not enough money to continue the trip. You need {money}$ more." –
    if the budget is not enough
  • "You have reached the destination. You have {money}$ budget left." – if it’s enough.
0
14/03/2019 10:14:59
yolowski avatar yolowski 0 Точки

Благодаря ти ! 

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