Advertisement
AlexJC

On Time for the Exam

Aug 27th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 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 On_Time_for_the_Exam
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int correctHour = int.Parse(Console.ReadLine());
  14. int correctMinutes = int.Parse(Console.ReadLine());
  15. int arriveHour = int.Parse(Console.ReadLine());
  16. int arriveMinutes = int.Parse(Console.ReadLine());
  17.  
  18. int correctTime = correctHour * 60 + correctMinutes;
  19. int arriveTime = arriveHour * 60 + arriveMinutes;
  20. int earlyMinutes = correctTime - 30;
  21.  
  22. int diff = 0;
  23.  
  24. if (arriveTime == correctTime)
  25. {
  26. Console.WriteLine("On time");
  27. }
  28. else if (arriveTime > correctTime)
  29. {
  30. Console.WriteLine("Late");
  31.  
  32. diff = arriveTime - correctTime;
  33. int hours = diff / 60;
  34. int minutes = diff % 60;
  35. if (hours > 0)
  36. {
  37. Console.WriteLine("{0}:{1:D2} hours after the start", hours, minutes);
  38. }
  39. else
  40. {
  41. Console.WriteLine("{0} minutes after the start", minutes);
  42. }
  43. }
  44. else if (arriveTime >= earlyMinutes)
  45. {
  46. Console.WriteLine("On time");
  47. diff = correctTime - arriveTime;
  48. int hours = diff / 60;
  49. int minutes = diff % 60;
  50. if (hours > 0)
  51. {
  52. Console.WriteLine("{0}:{1:D2} hours before the start", hours, minutes);
  53. }
  54. else
  55. {
  56. Console.WriteLine("{0} minutes before the start", minutes);
  57. }
  58.  
  59. }
  60. else
  61. {
  62. Console.WriteLine("Early");
  63. diff = correctTime - arriveTime;
  64. int hours = diff / 60;
  65. int minutes = diff % 60;
  66. if (hours > 0)
  67. {
  68. Console.WriteLine("{0}:{1:D2} hours before the start", hours, minutes);
  69. }
  70. else
  71. {
  72. Console.WriteLine("{0} minutes before the start", minutes);
  73. }
  74. }
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement