Advertisement
Zaksofon

Untitled

Feb 1st, 2020
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.18 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 flowers = Console.ReadLine();
  10.             int flowersCount = int.Parse(Console.ReadLine());
  11.             int budget = int.Parse(Console.ReadLine());
  12.             Double price = 0;
  13.             Double discount = 0;
  14.  
  15.             if (flowers == "Roses")
  16.             {
  17.                 price = flowersCount * 5;              
  18.                 if (flowersCount > 80)
  19.                 {
  20.                     discount = 0.1;
  21.                     price = price - (price * discount);
  22.                 }
  23.             }
  24.             else if (flowers == "Dahlias")
  25.             {
  26.                 price = flowersCount * 3.8;
  27.                 if (flowersCount > 90)
  28.                 {
  29.                     discount = 0.15;
  30.                     price = price - (price * discount);
  31.                 }
  32.             }
  33.             else if (flowers == "Tulips")
  34.             {
  35.                 price = flowersCount * 2.8;
  36.                 if (flowersCount > 80)
  37.                 {
  38.                     discount = 0.15;
  39.                     price = price - (price * discount);
  40.                 }
  41.             }
  42.             else if (flowers == "Narcissus")
  43.             {
  44.                 price = flowersCount * 3.0;
  45.                 if (flowersCount < 120)
  46.                 {
  47.                     discount = 1.15;
  48.                     price = price * discount;
  49.                 }
  50.             }
  51.             else if (flowers == "Gladiolus")
  52.             {
  53.                 price = flowersCount * 2.5;
  54.                 if (flowersCount < 80)
  55.                 {
  56.                     discount = 1.20;
  57.                     price = price  * discount;
  58.                 }
  59.             }
  60.            
  61.             if ((budget - price) > 0)
  62.             {
  63.                 Console.WriteLine($"Hey, you have a great garden with {flowersCount} {flowers} and {budget - price:f2} leva left.");
  64.             }
  65.             else if ((budget - price) < 0)
  66.             {
  67.                 Console.WriteLine($"Not enough money, you need {(budget - price) * -1:F2} leva more.");
  68.             }
  69.         }
  70.     }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement