Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.41 KB | None | 0 0
  1. using System;
  2.  
  3. namespace NewHouse
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             // read type of flower
  10.             string flowerType = Console.ReadLine();
  11.             // read number of flowers - int number
  12.             int flowerCount = int.Parse(Console.ReadLine());
  13.             // read budget
  14.             double budget = double.Parse(Console.ReadLine());
  15.             // check for discount or surcharge
  16.             double priceOfRoses = 5.00 * flowerCount;
  17.             double priceOfDahlias = 3.80 * flowerCount;
  18.             double priceOfTulips = 2.80 * flowerCount;
  19.             double priceOfNarcissus = 3.00 * flowerCount;
  20.             double priceOfGladiolus = 2.50 * flowerCount;
  21.  
  22.             double discount = 0;
  23.             double surcharge = 0;
  24.             double finalPrice = 0;
  25.  
  26.             switch (flowerType)
  27.             {
  28.                 case "Roses":
  29.                     if (flowerCount > 80)
  30.                     {
  31.                         discount = 0.1 * priceOfRoses;
  32.                         finalPrice = priceOfRoses - discount;
  33.  
  34.                     }
  35.                     else
  36.                     {
  37.                         finalPrice = priceOfRoses;
  38.                     }
  39.                     break;
  40.                 case "Dahlias":
  41.                     if (flowerCount > 90)
  42.                     {
  43.                         discount = 0.15 * priceOfDahlias;
  44.                         finalPrice = priceOfDahlias - discount;
  45.  
  46.                     }
  47.                     else
  48.                     {
  49.                         finalPrice = priceOfDahlias;
  50.                     }
  51.                     break;
  52.                 case "Tulips":
  53.                     if (flowerCount > 80)
  54.                     {
  55.                         discount = 0.15 * priceOfTulips;
  56.                         finalPrice = priceOfTulips - discount;
  57.  
  58.                     }
  59.                     else
  60.                     {
  61.                         finalPrice = priceOfTulips;
  62.                     }
  63.                     break;
  64.                 case "Narcissus":
  65.                     if (flowerCount < 120)
  66.                     {
  67.                         surcharge = 0.15 * priceOfNarcissus;
  68.                         finalPrice = priceOfNarcissus + surcharge;
  69.  
  70.                     }
  71.                     else
  72.                     {
  73.                         finalPrice = priceOfNarcissus;
  74.                     }
  75.                     break;
  76.                 case "Gladiolus":
  77.                     if (flowerCount < 80)
  78.                     {
  79.                         surcharge = 0.20 * priceOfGladiolus;
  80.                         finalPrice = priceOfGladiolus + surcharge;
  81.  
  82.                     }
  83.                     else
  84.                     {
  85.                         finalPrice = priceOfGladiolus;
  86.                     }
  87.                     break;
  88.             }
  89.             // check if budget is enough and print respective result
  90.             if (budget >= finalPrice)
  91.             {
  92.                 double leftover = budget - finalPrice;
  93.                 Console.WriteLine($"Hey, you have a great garden with {flowerCount} {flowerType} and {leftover:f2} leva left.");
  94.             }
  95.             else
  96.             {
  97.                 double shortage = finalPrice - budget;
  98.                 Console.WriteLine($"Not enough money, you need {shortage:f2} leva more.");
  99.             }
  100.            
  101.         }
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement