Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DomashnoNewHouse
- {
- class Program
- {
- static void Main(string[] args)
- {
- // get input : flowerType --> "Roses", "Dahlias", "Tulips", "Narcissus", "Gladiolus" ; int flowerNumber; int budget
- string flowerTypeInput = Console.ReadLine();
- string flowerType = flowerTypeInput.ToLower();
- int flowerNumber = int.Parse(Console.ReadLine());
- int budget = int.Parse(Console.ReadLine());
- // calculate how much does it cost
- double totalCost = 0.00;
- double rosesPrice = 5.00;
- double dahliasPrice = 3.80;
- double tulipsPrice = 2.80;
- double narcissusPrice = 3.00;
- double gladiolusPrice = 2.50;
- double rosesDiscountPercent = 10; // discount of 10% for more than 80 roses
- double dahliasDiscountPercent = 15; // discount of 15% for more than 90 dahlias
- double tulipsDiscountPercent = 15; // discount of 15% for more than 90 tulips
- double narcissusAddPercent = 15; // add 15% to price if less than 120 narcisus
- double gladiolusAddPercent = 20; // add 20% to price if less than 80 narcisus
- switch (flowerType)
- {
- case "roses":
- if (flowerNumber <= 80)
- {
- totalCost = rosesPrice * flowerNumber;
- }
- else
- {
- totalCost = rosesPrice * flowerNumber * (1 - (1.00 * rosesDiscountPercent / 100));
- }
- break;
- case "dahlias":
- if (flowerNumber <= 90)
- {
- totalCost = dahliasPrice * flowerNumber;
- }
- else
- {
- totalCost = dahliasPrice * flowerNumber * (1 - (1.00 * dahliasDiscountPercent / 100));
- }
- break;
- case "tulips":
- if (flowerNumber <= 80)
- {
- totalCost = tulipsPrice * flowerNumber;
- }
- else
- {
- totalCost = tulipsPrice * flowerNumber * (1 - (1.00 * tulipsDiscountPercent / 100));
- }
- break;
- case "narcissus":
- if (flowerNumber >= 120)
- {
- totalCost = 1.00 * narcissusPrice * flowerNumber;
- }
- else
- {
- totalCost = narcissusPrice * flowerNumber * (1 + (1.00 * narcissusAddPercent / 100));
- }
- break;
- case "gladiolus":
- if (flowerNumber >= 80)
- {
- totalCost = gladiolusPrice * flowerNumber;
- }
- else
- {
- totalCost = gladiolusPrice * flowerNumber * (1 + (1.00 * gladiolusAddPercent / 100));
- }
- break;
- }
- // calculate if it is enough
- bool isBudgetEnough = totalCost <= budget;
- // calculate how much more is needed or how much is left
- double moneyMoreNeeded = 0.00;
- double moneyLeft = 0.00;
- if (isBudgetEnough)
- {
- moneyLeft = budget - totalCost;
- }
- else
- {
- moneyMoreNeeded = Math.Abs(budget - totalCost);
- }
- // print --> "Hey, you have a great garden with {броя цвета} {вид цветя} and {останалата сума} leva left." / "Not enough money, you need {нужната сума} leva more."
- if (isBudgetEnough)
- {
- Console.WriteLine($"Hey, you have a great garden with {flowerNumber} {flowerTypeInput} and {moneyLeft:f2} leva left.");
- }
- else
- {
- Console.WriteLine($"Not enough money, you need {moneyMoreNeeded:f2} leva more.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement