Advertisement
Guest User

Untitled

a guest
May 30th, 2018
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4.  
  5. namespace ObjectClassSecondProblem
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11.  
  12.  
  13. DateTime startDate = DateTime.ParseExact(Console.ReadLine(), "dd-MM-yyyy", CultureInfo.InvariantCulture);
  14. DateTime endDate = DateTime.ParseExact(Console.ReadLine(), "dd-MM-yyyy", CultureInfo.InvariantCulture);
  15.  
  16. int workingDays = 0;
  17. bool holiday = false;
  18.  
  19. List<DateTime> holidays = new List<DateTime>()
  20. {
  21. DateTime.ParseExact("01-01-1970", "dd-MM-yyyy", CultureInfo.InvariantCulture),
  22. DateTime.ParseExact("03-03-1970", "dd-MM-yyyy", CultureInfo.InvariantCulture),
  23. DateTime.ParseExact("01-05-1970", "dd-MM-yyyy", CultureInfo.InvariantCulture),
  24. DateTime.ParseExact("06-05-1970", "dd-MM-yyyy", CultureInfo.InvariantCulture),
  25. DateTime.ParseExact("24-05-1970", "dd-MM-yyyy", CultureInfo.InvariantCulture),
  26. DateTime.ParseExact("06-09-1970", "dd-MM-yyyy", CultureInfo.InvariantCulture),
  27. DateTime.ParseExact("22-09-1970", "dd-MM-yyyy", CultureInfo.InvariantCulture),
  28. DateTime.ParseExact("01-11-1970", "dd-MM-yyyy", CultureInfo.InvariantCulture),
  29. DateTime.ParseExact("24-12-1970", "dd-MM-yyyy", CultureInfo.InvariantCulture),
  30. DateTime.ParseExact("25-12-1970", "dd-MM-yyyy", CultureInfo.InvariantCulture),
  31. DateTime.ParseExact("26-12-1970", "dd-MM-yyyy", CultureInfo.InvariantCulture),
  32. };
  33.  
  34. for (DateTime i = startDate; i <= endDate; i = i.AddDays(1))
  35. {
  36. if (i.DayOfWeek.Equals("Saturday") || i.DayOfWeek.Equals("Sunday"))
  37. {
  38. holiday = true;
  39. }
  40.  
  41. for (int j = 0; j < holidays.Count; j++)
  42. {
  43. if (i.Month == holidays[j].Month && i.Day == holidays[j].Day)
  44. {
  45. holiday = true;
  46. }
  47. }
  48.  
  49. if (!holiday)
  50. {
  51. workingDays++;
  52. }
  53.  
  54.  
  55. holiday = false;
  56.  
  57.  
  58. }
  59.  
  60. Console.WriteLine(workingDays);
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement