M0Hk

NewHouse

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