Aliendreamer

flowers

Mar 18th, 2017
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2.  
  3. class Flowers
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int chrys = int.Parse(Console.ReadLine());
  8.         int roses = int.Parse(Console.ReadLine());
  9.         int tulips = int.Parse(Console.ReadLine());
  10.         string season = Console.ReadLine();
  11.         char isHoliday = char.Parse(Console.ReadLine());
  12.  
  13.         double cPrice, rPrice, tPrice, seasonalDiscount = 0;
  14.         double totalFlowers = chrys + roses + tulips;
  15.  
  16.         if (season == "Spring" || season == "Summer")
  17.         {
  18.             cPrice = 2;
  19.             rPrice = 4.10;
  20.             tPrice = 2.50;
  21.  
  22.             if (tulips > 7 && season == "Spring") seasonalDiscount = 0.05;
  23.         }
  24.  
  25.  
  26.         else
  27.         {
  28.             cPrice = 3.75;
  29.             rPrice = 4.50;
  30.             tPrice = 4.15;
  31.  
  32.             if (roses >= 10 && season == "Winter") seasonalDiscount = 0.1;
  33.         }
  34.  
  35.         double generalDiscount = (totalFlowers > 20) ? 0.2 : 0;
  36.         double holidayExp = (isHoliday == 'Y') ? 0.15 : 0;
  37.         double totalExpenses = (cPrice * chrys + rPrice * roses + tPrice * tulips);
  38.         double holidayFlowers = totalExpenses + totalExpenses * holidayExp;
  39.         double seasonalExpenses = holidayFlowers - holidayFlowers * seasonalDiscount;
  40.         double generalExpenses = seasonalExpenses - seasonalExpenses * generalDiscount;
  41.         Console.Write((generalExpenses + 2).ToString("F"));
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment