Advertisement
yanass

Christmas Spirit Retake Mid Exam - 18 December 2018

Jun 27th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Christmas_Spirit
  6. {
  7.     class Program
  8.     {
  9.         static void Main()
  10.         {
  11.             var decorPrices = new Decorations(2, 5, 3, 15);
  12.  
  13.             int quantity = int.Parse(Console.ReadLine());
  14.  
  15.             int days = int.Parse(Console.ReadLine());
  16.  
  17.             int christmasSpirit = 0;
  18.  
  19.             int cost = 0;
  20.  
  21.             for (int i = 1; i <= days; i++)
  22.             {
  23.                 if (i % 11 == 0)
  24.                 {
  25.                     quantity += 2;
  26.                 }
  27.  
  28.                 if (i % 2 == 0)
  29.                 {
  30.                     cost += quantity * decorPrices.OrnamentSet;
  31.                     christmasSpirit += 5;
  32.                 }
  33.  
  34.                 if (i % 3 == 0)
  35.                 {
  36.                     cost += quantity * (decorPrices.TreeSkirt + decorPrices.TreeGarlands);
  37.                     christmasSpirit += 13;
  38.                 }
  39.  
  40.                 if (i % 5 == 0)
  41.                 {
  42.                     cost += quantity * decorPrices.TreeLights;
  43.                     christmasSpirit += 17;
  44.  
  45.                     if (i % 3 == 0)
  46.                     {
  47.                         christmasSpirit += 30;
  48.                     }
  49.                 }
  50.  
  51.                 if (i % 10 == 0)
  52.                 {
  53.                     christmasSpirit -= 20;
  54.  
  55.                     cost += decorPrices.TreeSkirt + decorPrices.TreeGarlands + decorPrices.TreeLights;                  
  56.  
  57.                     if (i == days)
  58.                     {
  59.                         christmasSpirit -= 30;
  60.                     }
  61.                 }
  62.             }
  63.  
  64.             Console.WriteLine($"Total cost: {cost}");
  65.             Console.WriteLine($"Total spirit: {christmasSpirit}");
  66.  
  67.         }
  68.     }
  69.  
  70.   class Decorations
  71.     {
  72.         public Decorations(int ornamentSet, int treeSkirt, int treeGarlands, int treeLights)
  73.         {
  74.             OrnamentSet = ornamentSet;
  75.             TreeSkirt = treeSkirt;
  76.             TreeGarlands = treeGarlands;
  77.             TreeLights = treeLights;
  78.  
  79.         }
  80.         public int OrnamentSet { get; set; }
  81.         public int TreeSkirt { get; set; }
  82.         public int TreeGarlands { get; set; }
  83.         public int TreeLights { get; set; }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement