Advertisement
spasnikolov131

Untitled

May 16th, 2023
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Hotel_Room
  4. {
  5. internal class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int examHours = int.Parse(Console.ReadLine());
  10. int examMinutes = int.Parse(Console.ReadLine());
  11. int arriveHours = int.Parse(Console.ReadLine());
  12. int arriveMinutes = int.Parse(Console.ReadLine());
  13.  
  14. int arriveHoursMinutes = arriveMinutes + arriveHours * 60;
  15. int examHoursMinutes = examMinutes + examHours * 60;
  16.  
  17. int hours = 0;
  18. int minutes = 0;
  19.  
  20. if (examHours == arriveHours && examMinutes == arriveMinutes)
  21. {
  22. Console.WriteLine("On time");
  23. }
  24.  
  25. else if (examHoursMinutes > arriveHoursMinutes)
  26. {
  27. int earlyMinutes = examHoursMinutes - arriveHoursMinutes;
  28. int earlyHours = examHours - arriveHours;
  29. hours = earlyMinutes / 60;
  30. minutes = earlyMinutes % 60;
  31. if (earlyHours >= 1 && examMinutes >= arriveMinutes)
  32. {
  33. Console.WriteLine($"Early {earlyHours}:{minutes:d2} hours before the start");
  34. }
  35. else
  36. {
  37.  
  38. if (minutes <= 30 || examMinutes == arriveMinutes)
  39. {
  40. Console.WriteLine($"On time {minutes} minutes before the start");
  41. }
  42. else if (hours >= 1 || minutes > 30 && minutes > 59)
  43. {
  44. Console.WriteLine($"Early {hours}:{minutes} hours before the start");
  45. }
  46. else if (minutes <= 59)
  47. {
  48. Console.WriteLine($"Early {minutes} minutes before the start");
  49. }
  50. }
  51. }
  52. else
  53. {
  54. int lateMinutes = arriveHoursMinutes - examHoursMinutes;
  55. hours = lateMinutes / 60;
  56. minutes = lateMinutes % 60;
  57. if (hours >= 1 || minutes > 59)
  58. {
  59. Console.WriteLine($"Late {hours}:{minutes} hours after the start");
  60. }
  61. else if (minutes <= 59)
  62. {
  63. Console.WriteLine($"Late {minutes} minutes after the start");
  64. }
  65. }
  66.  
  67. }
  68. }
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement