Advertisement
G_Burlakova

MaxNumberLectures

Feb 20th, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace CountLechtures
  7. {
  8.     class CountLectures
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Console.Write("Enter starting date: ");
  13.             var startingDate = DateTime.Parse(Console.ReadLine());
  14.             Console.Write("Enter end date: ");
  15.             var endDate = DateTime.Parse(Console.ReadLine());
  16.             Console.Write("Day of the lectuce: ");
  17.             string day = Console.ReadLine();
  18.  
  19.             DayOfWeek dayw = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), day);
  20.  
  21.             int maxDaysCount = 0;
  22.             while (startingDate <= endDate)
  23.             {
  24.                 if (startingDate.DayOfWeek == dayw)
  25.                 {
  26.                     maxDaysCount++;
  27.                 }
  28.                 startingDate = startingDate.AddDays(1);
  29.             }
  30.             Console.WriteLine(maxDaysCount);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement