Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace NewHouse
- {
- class Program
- {
- static void Main(string[] args)
- {
- // read type of flower
- string flowerType = Console.ReadLine();
- // read number of flowers - int number
- int flowerCount = int.Parse(Console.ReadLine());
- // read budget
- double budget = double.Parse(Console.ReadLine());
- // check for discount or surcharge
- double priceOfRoses = 5.00 * flowerCount;
- double priceOfDahlias = 3.80 * flowerCount;
- double priceOfTulips = 2.80 * flowerCount;
- double priceOfNarcissus = 3.00 * flowerCount;
- double priceOfGladiolus = 2.50 * flowerCount;
- double discount = 0;
- double surcharge = 0;
- double finalPrice = 0;
- switch (flowerType)
- {
- case "Roses":
- if (flowerCount > 80)
- {
- discount = 0.1 * priceOfRoses;
- finalPrice = priceOfRoses - discount;
- }
- else
- {
- finalPrice = priceOfRoses;
- }
- break;
- case "Dahlias":
- if (flowerCount > 90)
- {
- discount = 0.15 * priceOfDahlias;
- finalPrice = priceOfDahlias - discount;
- }
- else
- {
- finalPrice = priceOfDahlias;
- }
- break;
- case "Tulips":
- if (flowerCount > 80)
- {
- discount = 0.15 * priceOfTulips;
- finalPrice = priceOfTulips - discount;
- }
- else
- {
- finalPrice = priceOfTulips;
- }
- break;
- case "Narcissus":
- if (flowerCount < 120)
- {
- surcharge = 0.15 * priceOfNarcissus;
- finalPrice = priceOfNarcissus + surcharge;
- }
- else
- {
- finalPrice = priceOfNarcissus;
- }
- break;
- case "Gladiolus":
- if (flowerCount < 80)
- {
- surcharge = 0.20 * priceOfGladiolus;
- finalPrice = priceOfGladiolus + surcharge;
- }
- else
- {
- finalPrice = priceOfGladiolus;
- }
- break;
- }
- // check if budget is enough and print respective result
- if (budget >= finalPrice)
- {
- double leftover = budget - finalPrice;
- Console.WriteLine($"Hey, you have a great garden with {flowerCount} {flowerType} and {leftover:f2} leva left.");
- }
- else
- {
- double shortage = finalPrice - budget;
- Console.WriteLine($"Not enough money, you need {shortage:f2} leva more.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement