fbinnzhivko

Dream Item 2.00

Mar 13th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System;
  2.  
  3. class DreamItem
  4. {
  5.     static void Main()
  6.     {
  7.         string[] input = Console.ReadLine().Split('\\');
  8.         string month = input[0];
  9.         decimal moneyPerHour = decimal.Parse(input[1]);
  10.         decimal hoursPerDay = decimal.Parse(input[2]);
  11.         decimal itemPrice = decimal.Parse(input[3]);
  12.  
  13.         int days;
  14.         switch (month)
  15.         {
  16.             case "Feb": days = 28; break;
  17.             case "Apr":
  18.             case "June":
  19.             case "Sept":
  20.             case "Nov": days = 30; break;
  21.             default: days = 31; break;
  22.         }
  23.         //Holidays;
  24.         days -= 10;
  25.         //Total money;
  26.         decimal totalMoney = days * moneyPerHour * hoursPerDay;
  27.         //Bonus;
  28.         if (totalMoney > 700)
  29.         {
  30.             totalMoney += totalMoney * 0.1M;
  31.         }
  32.         //Check if enough to buy the item;
  33.         if (totalMoney - itemPrice >= 0)
  34.         {
  35.             Console.WriteLine("Money left = {0:F2} leva.", totalMoney - itemPrice);
  36.         }
  37.         else
  38.         {
  39.             Console.WriteLine("Not enough money. {0:F2} leva needed.", itemPrice - totalMoney);
  40.         }
  41.     }
  42. }
Add Comment
Please, Sign In to add comment