Loading...

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

VasilKos avatar VasilKos 17 Точки

BakeryShop

C# Advanced Exam - 20 February 2022 - SoftUni Judge

Зада4ата е BakeryShop от C#, аз я решавам на Java. Ako може помощ за принтирането: Flour left: 5.0, 15.0

Опитвам се да махна ".0" накрая

BakeryShop - Pastebin.com   

Условие:

Create a program that calculates the ratio between water and flour for predefined bakery products.

You will be given two sequences of real numbers, representing water and flour.

You should start from the first water and mix it with the last flour. If the ratio of water/flour corresponds to some of the following bakery products:

  • Croissant – consists of 50% water and 50% flour
  • Muffin – consists of 40% water and 60% flour
  • Baguette – consists of 30% water and 70% flour
  • Bagel – consists of 20% water and 80% flour

Create the corresponding bakery product and remove both the water and the flour from each collection.

If none of the products could be made, you should create the best-selling bakery product which is Croissant. To bake a Croissant, take only so much flour to meet the required ratio of 50% water and 50% flour. The water is removed, and all the excessive flour should be inserted back into the collection. You should stop mixing when you have no more flour or water left.

As a result, you should print two lines for output

  • On the first line print all the products which were baked ordered by amount baked descending, then by name of the products alphabetically.
  • On the second line print how much water and flour have left.

Input

  • On the first line, you will receive a sequence of real numbers representing the amount of water, separated by a single space (" ").
  • On the second line, you will receive a sequence of real numbers representing the flour, separated by a single space (" ").

Output

  • On the first line print only products which were baked successfully and how many of them, ordered by amount baked descending, then by product name alphabetically:
    • {product name}: {amount baked}

{product name}: {amount baked}

  •  
  •  
  • On the second line - print all water you have left:
    • If there is no water: "Water left: None"
    • If there are water left unused: "Water left: { water1}, { water2}, { water3}, (…)"
  • On the third line - print all flour you have left:
    • If there is no flour: "Flour left: None"
    • If there are flour left unused: "Flour left: { flour1}, { flour2}, { flour3}, (…)"

Constraints

  • All numbers will be in rage [1.0…100.0].
  • The input will be always valid.
  • The flour will never go below zero.

Examples

Input

Output

16.8 32.4 19.5 25

15 30 45.5 48.6 25.2

Muffin: 2

Baguette: 1

Croissant: 1

Water left: None

Flour left: 5, 15

Тагове:
0
Java Advanced
MartinBG avatar MartinBG 4803 Точки

Погледнете точка 4 в този пост, както и тази тема

0
VasilKos avatar VasilKos 17 Точки

MartinBG,

благодаря за бързия отговор.

Срещам трудност при имплементацията на Decimal Format в моето решение. (Никога не съм харесвал class-a Decimal Format :))

Дали може да покажете как да се имплементира в моя слу4ай при принта. Или друг вариант за принтиране.

0
MartinBG avatar MartinBG 4803 Точки
DecimalFormat df = new DecimalFormat("0.##");
System.out.println(df.format(1.00d)); // -> 1

// или в Stream

System.out.printf("Water left: %s%n", queueWater.stream().map(df::format).collect(Collectors.joining(", ")));

 

1
VasilKos avatar VasilKos 17 Точки

Благодарско , Мартин.

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