Advertisement
Guest User

Untitled

a guest
Oct 20th, 2021
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.59 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03.Flowers
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int chrysanthemums = int.Parse(Console.ReadLine());
  10.             int roses = int.Parse(Console.ReadLine());
  11.             int tulips = int.Parse(Console.ReadLine());
  12.             string season = Console.ReadLine();  
  13.             string day = Console.ReadLine();
  14.  
  15.             int workPrice = 2;
  16.             double chrysanthemumsPrice = 0.00;
  17.             double rosesPrice = 0.00;
  18.             double tulipssPrice = 0.00;
  19.  
  20.             switch (season)
  21.             {
  22.                 case "Spring":
  23.                 case "Summer":
  24.                     chrysanthemumsPrice = 2.00;
  25.                     rosesPrice = 4.10;
  26.                     tulipssPrice = 2.50;
  27.                     break;
  28.                 case "Autumn":
  29.                 case "Winter":
  30.                     chrysanthemumsPrice = 3.75;
  31.                     rosesPrice = 4.50;
  32.                     tulipssPrice = 4.15;
  33.                     break;
  34.             }
  35.  
  36.             double price = chrysanthemums * chrysanthemumsPrice + roses * rosesPrice + tulips * tulipssPrice;
  37.             int flowers = chrysanthemums + roses + tulips;
  38.  
  39.             if (day == "Y")
  40.             {
  41.                 price += price * 0.15;
  42.                 if (tulips > 7 && season == "Spring")
  43.                 {
  44.                     price -= price * 0.05;
  45.                 }
  46.                 else if (roses >= 10 && season == "Winter")
  47.                 {
  48.                     price -= price * 0.10;
  49.                 }
  50.                 if ((flowers > 20) && season == "Spring" || season == "Summer" || season == "Autumn" || season == "Winter")
  51.                 {
  52.                     price -= price * 0.20;
  53.                 }
  54.  
  55.                 double finalPrice = price + workPrice;
  56.                 Console.WriteLine($"{finalPrice:f2}");
  57.             }
  58.             else if (day == "N")
  59.             {
  60.                 if (tulips > 7 && season == "Spring")
  61.                 {
  62.                     price -= price * 0.05;
  63.                 }
  64.                 else if (roses >= 10 && season == "Winter")
  65.                 {
  66.                     price -= price * 0.10;
  67.                 }
  68.                 if (((chrysanthemums + roses + tulips) > 20) && season == "Spring" || season == "Summer" || season == "Autumn" || season == "Winter")
  69.                 {
  70.                     price -= price * 0.20;
  71.                 }
  72.                 double finalPrice = price + workPrice;
  73.                 Console.WriteLine($"{finalPrice:f2}");
  74.             }
  75.         }
  76.     }
  77. }
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement