KlimentHristov

**DreamItem

Nov 11th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.04 KB | None | 0 0
  1. using System;
  2. class DreamItem
  3. {
  4.     static void Main()
  5.     {
  6.         string input = Console.ReadLine();
  7.  
  8.         string[] stringArray = input.Split(new Char[] { '\\' });
  9.  
  10.         string month = stringArray[0];
  11.         decimal moneyPerHour = decimal.Parse(stringArray[1]);
  12.         decimal hoursPerDay = decimal.Parse(stringArray[2]);
  13.         decimal item = decimal.Parse(stringArray[3]);
  14.  
  15.         decimal daysInMonth = Months(month);
  16.  
  17.         decimal workDays = daysInMonth - 10;
  18.  
  19.         decimal salary = (workDays * hoursPerDay * moneyPerHour);
  20.         decimal bonus = (decimal)((float)salary * 0.1);
  21.  
  22.         if (salary > 700)
  23.         {
  24.             salary += bonus;
  25.         }
  26.  
  27.         if (salary >= item)
  28.         {
  29.             decimal result = salary - item;
  30.  
  31.             Console.WriteLine("Money left = {0:0.00} leva.", result);
  32.         }
  33.         else
  34.         {
  35.             decimal result = 0;
  36.  
  37.             if (salary > 0)
  38.             {
  39.                 result = item - salary;
  40.             }
  41.             else
  42.             {
  43.                 result = salary - item;
  44.                 result *= -1;
  45.             }
  46.  
  47.             Console.WriteLine("Not enough money. {0:0.00} leva needed.", result);
  48.         }
  49.  
  50.     }
  51.  
  52.     public static decimal Months(string input)
  53.     {
  54.         switch (input)
  55.         {
  56.             case "Jan":
  57.                 return 31;
  58.  
  59.             case "Feb":
  60.                 return 28;
  61.  
  62.             case "March":
  63.                 return 31;
  64.  
  65.             case "Apr":
  66.                 return 30;
  67.  
  68.             case "May":
  69.                 return 31;
  70.  
  71.             case "June":
  72.                 return 30;
  73.  
  74.             case "July":
  75.                 return 31;
  76.  
  77.             case "Aug":
  78.                 return 31;
  79.  
  80.             case "Sept":
  81.                 return 30;
  82.  
  83.             case "Oct":
  84.                 return 31;
  85.  
  86.             case "Nov":
  87.                 return 30;
  88.  
  89.             case "Dec":
  90.                 return 31;
  91.  
  92.             default:
  93.                 return 0;
  94.         }
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment