Advertisement
Guest User

03.Flowers

a guest
Feb 3rd, 2017
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 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 flowers_2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int chrysantemums = int.Parse(Console.ReadLine());
  14.             int roses = int.Parse(Console.ReadLine());
  15.             int tulips = int.Parse(Console.ReadLine());
  16.             string season = Console.ReadLine();
  17.  
  18.             bool isHoliday = Console.ReadLine() == "Y" ? true : false;
  19.             int totalFlowers = chrysantemums + roses + tulips;
  20.             double totalPrice;
  21.             bool flowersMoreThanTwenty = totalFlowers >= 20;
  22.             if (season == "Spring" || season == "Summer")
  23.             {
  24.                 totalPrice = chrysantemums * 2 + roses * 4.1 + tulips * 2.5;
  25.                 bool tulipDiscount = tulips > 7 && season == "Spring";
  26.                 if (isHoliday)
  27.                 {
  28.                     totalPrice *= 1.15;
  29.                 }
  30.                 if (tulipDiscount)
  31.                 {
  32.                     totalPrice *= 0.95;
  33.                 }
  34.             }
  35.             else
  36.             {
  37.                 totalPrice = chrysantemums * 3.75 + roses * 4.5 + tulips *4.15;
  38.                 bool roseDiscount = roses >= 10 && season == "Winter";
  39.                 if (isHoliday)
  40.                 {
  41.                     totalPrice *= 1.15;
  42.                 }
  43.                 if (roseDiscount)
  44.                 {
  45.                     totalPrice *= 0.9;
  46.                 }
  47.             }
  48.  
  49.             if (flowersMoreThanTwenty)
  50.             {
  51.                 totalPrice *= 0.8;
  52.             }
  53.  
  54.             totalPrice+=2;
  55.             Console.WriteLine("{0:f2}",totalPrice);
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement