Advertisement
zdravko7

Exam 29 March 2015 Evening Ex_2

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