Advertisement
Guest User

Untitled

a guest
Apr 6th, 2016
1,460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 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. namespace Practice
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int hourExam = int.Parse(Console.ReadLine());
  14. int minuteExam = int.Parse(Console.ReadLine());
  15. int hourArrive = int.Parse(Console.ReadLine());
  16. int minuteArrive = int.Parse(Console.ReadLine());
  17. if (hourExam==0)
  18. {
  19. hourExam = 24;
  20. }
  21. if (hourArrive==0)
  22. {
  23. hourArrive = 24;
  24. }
  25.  
  26. TimeSpan exam = TimeSpan.FromHours(hourExam) + TimeSpan.FromMinutes(minuteExam);
  27. TimeSpan arrive = TimeSpan.FromHours(hourArrive) + TimeSpan.FromMinutes(minuteArrive);
  28. TimeSpan result = TimeSpan.MinValue;
  29.  
  30. int hours = 0;
  31. int minutes = 0;
  32. TimeSpan zero = TimeSpan.Zero;
  33. int thirthyForMinutes = 30;
  34. int oneForHour = 1;
  35. TimeSpan thirthy = TimeSpan.FromMinutes(thirthyForMinutes);
  36. TimeSpan oneHour = TimeSpan.FromHours(oneForHour);
  37. if (exam >= arrive)
  38. {
  39. result = exam - arrive;
  40. hours = result.Hours;
  41. minutes = result.Minutes;
  42. if (exam == arrive)
  43. {
  44. Console.WriteLine("On time");
  45. }
  46. else if (result<=thirthy)
  47. {
  48. Console.WriteLine("On time");
  49. Console.WriteLine("{0} minutes before the start",minutes);
  50. }
  51. else if (result>= thirthy && result < oneHour)
  52. {
  53. Console.WriteLine("Early");
  54. Console.WriteLine("{0} minutes before the start", minutes);
  55. }
  56. else if (result>= oneHour)
  57. {
  58. Console.WriteLine("Early");
  59. Console.WriteLine("{0}:{1:d2} hours before the start",hours,minutes);
  60. }
  61. }
  62. else
  63. {
  64. result = arrive - exam;
  65. hours = result.Hours;
  66. minutes = result.Minutes;
  67. if (result<oneHour)
  68. {
  69. Console.WriteLine("Late");
  70. Console.WriteLine("{0} minutes after the start", minutes);
  71. }
  72. if (result>oneHour)
  73. {
  74. Console.WriteLine("Late");
  75. Console.WriteLine("{0}:{1:d2} hours after the start", hours, minutes);
  76. }
  77. }
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement