Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _03._New_House
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string flowerType = Console.ReadLine(); // "Roses", "Dahlias", "Tulips", "Narcissus", "Gladiolus"
- int count = int.Parse(Console.ReadLine()); //брой цветята
- int budget = int.Parse(Console.ReadLine()); //предвиден бюджет
- //1. крайна цена = бр. цветята (count) * цена за 1 цвете (priceFlower)
- double priceFlower = 0; //цена за 1 цвете, зависи от вид на цветето
- //flowerType -> серия от проверки за точни стойности
- //"Roses" -> 5
- //"Dahlias" -> 3.80
- //"Tulips" -> 2.80
- //"Narcissus" -> 3
- //"Gladiolus" -> 2.50
- switch (flowerType)
- {
- case "Roses":
- priceFlower = 5;
- break;
- case "Dahlias":
- priceFlower = 3.80;
- break;
- case "Tulips":
- priceFlower = 2.80;
- break;
- case "Narcissus":
- priceFlower = 3;
- break;
- case "Gladiolus":
- priceFlower = 2.50;
- break;
- }
- double totalPrice = count * priceFlower; //крайна цена
- //2. отстъпки
- //повече от 80 Рози -> 10%
- if (count > 80 && flowerType == "Roses")
- {
- totalPrice = totalPrice - 0.10 * totalPrice;
- //totalPrice = 0.9 * totalPrice;
- //totalPrice *= 0.9;
- }
- //повече от 90 Далии - 15 %
- else if (count > 90 && flowerType == "Dahlias")
- {
- totalPrice = totalPrice - 0.15 * totalPrice;
- //totalPrice = 0.85 * totalPrice;
- //totalPrice *= 0.85;
- }
- //повече от 80 Лалета - 15%
- else if (count > 80 && flowerType == "Tulips")
- {
- totalPrice = totalPrice - 0.15 * totalPrice;
- //totalPrice = 0.85 * totalPrice;
- //totalPrice *= 0.85;
- }
- //по-малко от 120 Нарциса +15%
- else if (count < 120 && flowerType == "Narcissus")
- {
- totalPrice = totalPrice + 0.15 * totalPrice;
- //totalPrice = 1.15 * totalPrice;
- //totalPrice *= 1.15;
- }
- //по-малко от 80 Гладиоли + 20%
- else if (count < 80 && flowerType == "Gladiolus")
- {
- totalPrice = totalPrice + 0.20 * totalPrice;
- //totalPrice = 1.2 * totalPrice;
- //totalPrice *= 1.2;
- }
- //3. проверка за бюджетът
- //крайна сума: totalPrice
- //предвиденият бюджет: budget
- //достатъчен
- if (budget >= totalPrice)
- {
- double leftSum = budget - totalPrice; //останала сума
- Console.WriteLine($"Hey, you have a great garden with {count} {flowerType} and {leftSum:F2} leva left.");
- }
- else
- {
- //budget < totalPrice -> не е достатъчен
- double needSum = totalPrice - budget; //нужна сума
- Console.WriteLine($"Not enough money, you need {needSum:F2} leva more.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement