svephoto

NewHouse [C#]

Jul 23rd, 2021 (edited)
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.04 KB | None | 0 0
  1. using System;
  2.  
  3. namespace NewHouse
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string flowerType = Console.ReadLine();
  10.             int numberOfFlowers = int.Parse(Console.ReadLine());
  11.             int budget = int.Parse(Console.ReadLine());
  12.  
  13.             double totalSum = 0;
  14.  
  15.             switch (flowerType)
  16.             {
  17.                 case "Roses":
  18.                     totalSum = numberOfFlowers * 5;
  19.  
  20.                     if (numberOfFlowers > 80)
  21.                     {
  22.                         totalSum *= 0.9;
  23.                     }
  24.  
  25.                     break;
  26.                 case "Dahlias":
  27.                     totalSum = numberOfFlowers * 3.8;
  28.  
  29.                     if (numberOfFlowers > 90)
  30.                     {
  31.                         totalSum *= 0.85;
  32.                     }
  33.  
  34.                     break;
  35.                 case "Tulips":
  36.                     totalSum = numberOfFlowers * 2.8;
  37.  
  38.                     if (numberOfFlowers > 80)
  39.                     {
  40.                         totalSum *= 0.85;                    
  41.                     }
  42.  
  43.                     break;
  44.                 case "Narcissus":
  45.                     totalSum = numberOfFlowers * 3;
  46.  
  47.                     if (numberOfFlowers < 120)
  48.                     {
  49.                         totalSum *= 1.15;                    
  50.                     }
  51.  
  52.                     break;
  53.                 case "Gladiolus":
  54.                     totalSum = numberOfFlowers * 2.5;
  55.  
  56.                     if (numberOfFlowers < 80)
  57.                     {
  58.                         totalSum *= 1.2;
  59.                     }
  60.  
  61.                     break;
  62.             }
  63.  
  64.             if (budget >= totalSum)
  65.             {
  66.                 Console.WriteLine($"Hey, you have a great garden with {numberOfFlowers} {flowerType} and {budget - totalSum:f2} leva left.");
  67.             }
  68.             else
  69.             {
  70.                 Console.WriteLine($"Not enough money, you need {totalSum - budget:f2} leva more.");
  71.             }
  72.         }
  73.     }
  74. }
  75.  
Add Comment
Please, Sign In to add comment