saimun1

Programming basics Exam 18Dec 03. Flowers

May 8th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 KB | None | 0 0
  1. https://judge.softuni.bg/Contests/Practice/Index/368#0
  2. using System;
  3.  
  4. namespace Testing
  5. {
  6.     class MainClass
  7.     {
  8.         public static void Main (string[] args)
  9.  
  10.         {
  11.              
  12.             int chrys = int.Parse (Console.ReadLine ());
  13.             int roses = int.Parse (Console.ReadLine ());
  14.             int tulip = int.Parse (Console.ReadLine ());
  15.             string season = Console.ReadLine ();
  16.             string holidayCheck = Console.ReadLine ();
  17.  
  18.             float hrizPr = 0f;
  19.             float rosesPr = 0f;
  20.             float tulipPr = 0f;
  21.             float secondDiscount = 1f;
  22.  
  23.             var totalFlowers = chrys + roses + tulip;
  24.             float discountPrc =0;
  25.  
  26.             if (season == "Spring" || season == "Summer") {
  27.                
  28.                  hrizPr = 2.0f * chrys;
  29.                  rosesPr = 4.1f * roses;
  30.                  tulipPr = 2.5f * tulip;
  31.             }
  32.             if (season == "Winter" || season == "Autumn") {
  33.                  
  34.                  hrizPr = 3.75f * chrys;
  35.                  rosesPr = 4.50f * roses;
  36.                  tulipPr = 4.15f * tulip;
  37.             }
  38.             if (season == "Winter" && roses >= 10) {
  39.                 discountPrc += 0.10f;
  40.             }
  41.             if(season == "Spring" && tulip >7) {
  42.                 discountPrc = discountPrc + 0.05f;
  43.             }
  44.             if (totalFlowers > 20) {
  45.                  secondDiscount -= 0.2f;
  46.             }
  47.             float totalPrice =  rosesPr + tulipPr+hrizPr;
  48.             //Console.WriteLine (totalPrice);
  49.             if (holidayCheck == "Y") {
  50.                 totalPrice = totalPrice * 1.15f;
  51.                 //Console.WriteLine (totalPrice);
  52.  
  53.             }
  54.             var discount = 1 - discountPrc;
  55.             //Console.WriteLine (discountPrc);
  56.             totalPrice *= discount;
  57.             totalPrice *= secondDiscount;
  58.  
  59.             Console.WriteLine ("{0:f2}",totalPrice +2);
  60.  
  61.     }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment