Advertisement
Innos2000

Dream Item

Apr 24th, 2015
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 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.  
  8. class DreamItem
  9. {
  10.     static void Main()
  11.     {
  12.         var data = Console.ReadLine().Split('\\');
  13.  
  14.         string months = data[0];
  15.         int daysPerMonth;
  16.         decimal moneyPerHour = decimal.Parse(data[1]);
  17.         int hoursPerDay = int.Parse(data[2]);
  18.         decimal itemPrice = decimal.Parse(data[3]);
  19.  
  20.         switch (months)
  21.         {
  22.             case "Feb": daysPerMonth = 28 - 10;
  23.                 break;
  24.             case "Apr":
  25.             case "June":
  26.             case "Sept":
  27.             case "Nov": daysPerMonth = 30 - 10;
  28.                 break;
  29.             default: daysPerMonth = 31 - 10;
  30.                 break;
  31.         }
  32.  
  33.         decimal moneyPerMonth = (moneyPerHour * hoursPerDay) * daysPerMonth;
  34.  
  35.         if (moneyPerMonth > 700)
  36.         {
  37.             moneyPerMonth += (moneyPerMonth * 0.1m);
  38.         }
  39.  
  40.         if (moneyPerMonth >= itemPrice)
  41.         {
  42.             decimal output = moneyPerMonth - itemPrice;
  43.             Console.WriteLine("Money left = {0:F2} leva.", output);
  44.         }
  45.         else
  46.         {
  47.             decimal output = itemPrice - moneyPerMonth;
  48.             Console.WriteLine("Not enough money. {0:F2} leva needed.", output);
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement