Advertisement
GogoK

Untitled

Sep 20th, 2015
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class DreamItem
  5. {
  6.     static void Main()
  7.     {
  8.         string[] input = Console.ReadLine().Split('\\').ToArray();
  9.  
  10.         int daysInMonth = GetDaysInMonth(input[0]) - 10;
  11.         decimal moneyPerHour = decimal.Parse(input[1]);
  12.         decimal hoursPerDay = decimal.Parse(input[2]);
  13.         decimal priceOfItem = decimal.Parse(input[3]);
  14.  
  15.         decimal salary = (moneyPerHour * hoursPerDay) * daysInMonth;
  16.        
  17.         if (salary > 700)
  18.         {
  19.             salary *= (decimal)1.10;
  20.         }
  21.  
  22.         if (salary >= priceOfItem)
  23.         {
  24.             Console.WriteLine("Money left = {0:F} leva.", (salary - priceOfItem));
  25.         }
  26.         else
  27.         {
  28.             Console.WriteLine("Not enough money. {0:F} leva needed.", (priceOfItem - salary));
  29.         }
  30.     }
  31.     private static int GetDaysInMonth(string month)
  32.     {
  33.         int days = 0;
  34.         switch (month)
  35.         {
  36.             case "Jan": days = 31; break;
  37.             case "Feb": days = 28; break;
  38.             case "Mar": days = 31; break;
  39.             case "Apr": days = 30; break;
  40.             case "May": days = 31; break;
  41.             case "June": days = 30; break;
  42.             case "July": days = 31; break;
  43.             case "Aug": days = 31; break;
  44.             case "Sept": days = 30; break;
  45.             case "Oct": days = 31; break;
  46.             case "Nov": days = 30; break;
  47.             case "Dec": days = 31; break;
  48.         }
  49.         return days;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement