Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace delthis
- {
- using System;
- namespace NewHome
- {
- class Program
- {
- static void Main(string[] args)
- {
- string typeOfFlowers = Console.ReadLine();
- int numFlowers = int.Parse(Console.ReadLine());
- double budget = double.Parse(Console.ReadLine());
- double priceForOneFlower = 0;
- int threshold = 0;
- bool isPositiveThreshold = false;
- double coefficient = 0;
- if (typeOfFlowers == "Roses") //roses > 80 --> 10% discount
- {
- priceForOneFlower = 5;
- isPositiveThreshold = true;
- threshold = 80;
- coefficient = 0.9;
- }
- else if (typeOfFlowers == "Dahlias") //dahlias > 90 --> 15% discount
- {
- priceForOneFlower = 3.8;
- isPositiveThreshold = true;
- threshold = 90;
- coefficient = 0.85;
- }
- else if (typeOfFlowers == "Tulips") //tulips > 80 --> 15% discount
- {
- priceForOneFlower = 2.8;
- isPositiveThreshold = true;
- threshold = 80;
- coefficient = 0.85;
- }
- else if (typeOfFlowers == "Narcissus") //narcissus < 120 --> price * 15%
- {
- priceForOneFlower = 3;
- isPositiveThreshold = false;
- threshold = 120;
- coefficient = 1.15;
- }
- else if (typeOfFlowers == "Gladiolus") //gladiolus < 80 --> price * 20%
- {
- priceForOneFlower = 2.5;
- isPositiveThreshold = false;
- threshold = 80;
- coefficient = 1.2;
- }
- var totalPrice = priceForOneFlower * numFlowers;
- if ((isPositiveThreshold && numFlowers > threshold) ||
- (!isPositiveThreshold && numFlowers < threshold))
- {
- totalPrice *= coefficient;
- }
- double neededMoney = budget - totalPrice;
- if (neededMoney >= 0)
- {
- Console.WriteLine($"Hey, you have a great garden with {numFlowers} {typeOfFlowers} and {neededMoney:f2} leva left.");
- }
- else
- {
- Console.WriteLine($"Not enough money, you need {Math.Abs(neededMoney):f2} leva more.");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment