Advertisement
llozev91

New House

Jan 27th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.46 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 flower = Console.ReadLine();
  10.             int quantity = int.Parse(Console.ReadLine());
  11.             int budget = int.Parse(Console.ReadLine());
  12.  
  13.             double price = 0;
  14.             double moneyLeft = 0;
  15.             double moneyNeed = 0;
  16.  
  17.             switch (flower)
  18.             {
  19.                 case "Roses":
  20.                     if (quantity > 80)
  21.                     {
  22.                         price = (quantity * 5) * 0.9;
  23.                     }
  24.                     else
  25.                     {
  26.                         price = (quantity * 5);
  27.                     }
  28.                     break;;
  29.                 case "Dahlias":
  30.                     if (quantity > 90)
  31.                     {
  32.                         price = (quantity * 3.8) * 0.85;
  33.                     }
  34.                     else
  35.                     {
  36.                         price = (quantity * 3.8);
  37.                     }
  38.                     break;
  39.                 case "Tulips":
  40.                     if (quantity > 80)
  41.                     {
  42.                         price = (quantity * 2.8) * 0.85;
  43.                     }
  44.                     else
  45.                     {
  46.                         price = (quantity * 2.8);
  47.                     }
  48.                     break;
  49.                 case "Narcissus":
  50.                     if (quantity < 120)
  51.                     {
  52.                         price = (quantity * 3) * 1.15;
  53.                     }
  54.                     else
  55.                     {
  56.                         price = (quantity * 3);
  57.                     }
  58.                     break;
  59.                 case "Gladiolus":
  60.                     if (quantity < 80)
  61.                     {
  62.                         price = (quantity * 2.5) * 1.2;
  63.                     }
  64.                     else
  65.                     {
  66.                         price = (quantity * 2.5);
  67.                     }
  68.                     break;
  69.             }
  70.  
  71.  
  72.             if (budget >= price)
  73.             {
  74.                 moneyLeft = budget - price;
  75.                 Console.WriteLine($"Hey, you have a great garden with {quantity} {flower} and {moneyLeft:F2} leva left.");
  76.             }
  77.             else
  78.             {
  79.                 moneyNeed = price - budget;
  80.                 Console.WriteLine($"Not enough money, you need {moneyNeed:F2} leva more.");
  81.             }
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement