grach

2016_18_Dec_Flowers

Jul 20th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Flowers1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int hrizantemCount = int.Parse(Console.ReadLine());
  14.             int roseCount = int.Parse(Console.ReadLine());
  15.             int tulipCount = int.Parse(Console.ReadLine());
  16.  
  17.             string season = Console.ReadLine();
  18.             bool isHolyday = Console.ReadLine() == "Y";
  19.  
  20.             double flowerCost = 0;
  21.  
  22.             if (season == "Spring" || season == "Summer")
  23.             {
  24.                 flowerCost =
  25.                    hrizantemCount * 2 +
  26.                    roseCount * 4.1 +
  27.                    tulipCount * 2.5;
  28.                 if (tulipCount > 7 && season == "Spring")
  29.                 {
  30.                     flowerCost *= 0.95;
  31.                 }
  32.             }
  33.             else
  34.             {
  35.                 flowerCost =
  36.                    hrizantemCount * 3.75 +
  37.                    roseCount * 4.5 +
  38.                    tulipCount * 4.15;
  39.  
  40.                 if (roseCount >= 10 && season == "Winter")
  41.                     flowerCost *= 0.9;
  42.             }
  43.  
  44.             if (isHolyday)
  45.                 flowerCost *= 1.15;
  46.             if (hrizantemCount + roseCount + tulipCount > 20)
  47.                 flowerCost *= 0.8;
  48.  
  49.             flowerCost += 2;
  50.  
  51.             Console.WriteLine($"{flowerCost:f2}");
  52.         }
  53.     }
  54. }
  55.  
  56.  
  57. /*
  58. using System;
  59. using System.Collections.Generic;
  60. using System.Linq;
  61. using System.Text;
  62. using System.Threading.Tasks;
  63.  
  64. namespace Flowers
  65. {
  66.     class Program
  67.     {
  68.         static void Main(string[] args)
  69.         {
  70.             double quantityChris = int.Parse(Console.ReadLine());
  71.             double quantityRoses = int.Parse(Console.ReadLine());
  72.             double quantityTulip = int.Parse(Console.ReadLine());
  73.             string season = Console.ReadLine();
  74.             string holiday = Console.ReadLine();
  75.  
  76.             var count = quantityTulip + quantityRoses + quantityChris;
  77.  
  78.             double priceFlowers = 0;
  79.  
  80.             switch (season)
  81.             {
  82.                 case "Summer":
  83.                     quantityChris = 2.00 * quantityChris;
  84.                     quantityRoses = 4.10 * quantityRoses;
  85.                     quantityTulip = 2.50 * quantityTulip;
  86.                     break;
  87.                 case "Spring":
  88.                     quantityChris = 2.00 * quantityChris;
  89.                     quantityRoses = 4.10 * quantityRoses;
  90.                     quantityTulip = 2.50 * quantityTulip;
  91.                     break;
  92.                 case "Autumn":
  93.                     quantityChris = 3.75 * quantityChris;
  94.                     quantityRoses = 4.50 * quantityRoses;
  95.                     quantityTulip = 4.15 * quantityTulip;
  96.                     break;
  97.                 case "Winter":
  98.                     quantityChris = 3.75 * quantityChris;
  99.                     quantityRoses = 4.50 * quantityRoses;
  100.                     quantityTulip = 4.15 * quantityTulip;
  101.                     break;
  102.             }
  103.  
  104.             priceFlowers = (quantityChris + quantityRoses + quantityTulip);
  105.            
  106.             if (holiday == "Y")
  107.                priceFlowers *= 1.15;
  108.             if ( (quantityTulip >= 7) || (quantityRoses >= 10) )
  109.             if (season == "Spring")
  110.                 priceFlowers *= 0.95;
  111.             if (season == "Winter")
  112.                 priceFlowers *=  0.9;
  113.             if (count > 20)
  114.                 priceFlowers *= 0.8;
  115.            
  116.             Console.WriteLine("{0:f2}", priceFlowers+2 );
  117.         }
  118.     }
  119. }
  120. */
Advertisement
Add Comment
Please, Sign In to add comment