Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04._New_House
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string flowerType = Console.ReadLine();
  10.             int flowerNumber = int.Parse(Console.ReadLine());
  11.             int budget = int.Parse(Console.ReadLine());
  12.  
  13.             double singleFlowerPrice = 0;
  14.             switch (flowerType)
  15.             {
  16.                 case "Roses":
  17.                     singleFlowerPrice = 5;
  18.                     break;
  19.                 case "Dahlias":
  20.                     singleFlowerPrice = 3.80;
  21.                     break;
  22.                 case "Tulips":
  23.                     singleFlowerPrice = 2.80;
  24.                     break;
  25.                 case "Narcissus":
  26.                     singleFlowerPrice = 3;
  27.                     break;
  28.                 case "Gladiolus":
  29.                     singleFlowerPrice = 2.50;
  30.                     break;
  31.             }
  32.  
  33.             double totalPrice = flowerNumber * singleFlowerPrice;
  34.            
  35.             if (flowerNumber > 80 && flowerType == "Rose")
  36.             {
  37.                 totalPrice = totalPrice - totalPrice * 0.1;
  38.             }
  39.             else if (flowerNumber > 90 && flowerType == "Dahlias")
  40.             {
  41.                 totalPrice = totalPrice - totalPrice * 0.15;
  42.             }
  43.             else if (flowerNumber > 80 && flowerType == "Tulips")
  44.             {
  45.                 totalPrice = totalPrice - totalPrice * 0.1;
  46.             }
  47.             else if (flowerNumber < 120 &&  flowerType == "Narcissus")
  48.             {
  49.                 totalPrice = totalPrice + 0.15 * totalPrice;
  50.             }
  51.             else if (flowerNumber < 80 && flowerType == "Gladiolus")
  52.             {
  53.                 totalPrice = totalPrice + 0.2 * totalPrice;
  54.             }
  55.  
  56.             if (budget >= totalPrice)
  57.             {
  58.                 Console.WriteLine($"Hey, you have a great garden with {flowerNumber} {flowerType} and {(budget - totalPrice):F2} leva left.");
  59.             }
  60.             else
  61.                 Console.WriteLine($"Not enough money, you need {(totalPrice - budget):F2} leva more.");
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement