Advertisement
dimipan80

Exam 6. Exam Schedule

Jun 19th, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. namespace _1.ExamSchedule
  2. {
  3.     using System;
  4.     using System.Globalization;
  5.     using System.Threading;
  6.  
  7.     public class CalculateTimeTheExamEnd
  8.     {
  9.         public static void Main(string[] args)
  10.         {
  11.             Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  12.             checked
  13.             {
  14.                 string startHour = Console.ReadLine();
  15.                 string startMinutes = Console.ReadLine();
  16.                 string partOfDay = Console.ReadLine();
  17.                 int durationHours = int.Parse(Console.ReadLine());
  18.                 int durationMinutes = int.Parse(Console.ReadLine());
  19.  
  20.                 string timeStr = startHour + ':' + startMinutes + ' ' + partOfDay;                
  21.                 DateTime startTime = DateTime.Parse(timeStr);
  22.                 DateTime endTime = startTime.AddHours((double)durationHours);
  23.                 endTime = endTime.AddMinutes((double)durationMinutes);
  24.  
  25.                 Console.WriteLine(endTime.ToString("hh:mm:tt"));
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement