Innos2000

DI

Apr 25th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace DreamItem
  8. {
  9.     class DreamItem
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var input = Console.ReadLine().Split('\\');
  14.  
  15.             string month = input[0];
  16.             decimal moneyPerHour = decimal.Parse(input[1]);
  17.             decimal hoursPerDay = decimal.Parse(input[2]);
  18.             decimal itemPrice = decimal.Parse(input[3]);
  19.  
  20.             int daysPerMonth = 31;
  21.  
  22.             switch (month)
  23.             {
  24.                 case "Feb":
  25.                     daysPerMonth = 18;
  26.                     break;
  27.                 case "Apr":
  28.                 case "June":
  29.                 case "Sept":
  30.                 case "Nov":
  31.                     daysPerMonth = 20;
  32.                     break;
  33.                 default:
  34.                     daysPerMonth = 21;
  35.                     break;
  36.             }
  37.  
  38.             decimal hoursPerMonth = hoursPerDay * daysPerMonth;
  39.             decimal moneyPerMonth = hoursPerMonth * moneyPerHour;
  40.  
  41.             if (moneyPerMonth > 700)
  42.             {
  43.                 moneyPerMonth = moneyPerMonth + moneyPerMonth * 0.1M;
  44.  
  45.             }
  46.  
  47.             decimal moneyLeft = moneyPerMonth - itemPrice;
  48.             string output = "";
  49.  
  50.             if (moneyLeft >= 0)
  51.             {
  52.                 output = string.Format("Money left = {0:f2} leva.", moneyLeft);
  53.             }
  54.             else
  55.             {
  56.                 output = string.Format("Not enough money. {0:f2} leva needed.", Math.Abs(moneyLeft));
  57.             }
  58.             Console.WriteLine(output);
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment