Advertisement
sanyakasarova

On time for the exam

Jun 19th, 2021
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConditionalStatementsAdvanced
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int examHour = int.Parse(Console.ReadLine());
  10. int examMinute = int.Parse(Console.ReadLine());
  11.  
  12. int arriveHour = int.Parse(Console.ReadLine());
  13. int arriveMinute = int.Parse(Console.ReadLine());
  14.  
  15. int examMinutes = examHour * 60 + examMinute; //часът на изпита в минути
  16. int arriveMinutes = arriveHour * 60 + arriveMinute; //часът на пристигане в минути
  17.  
  18.  
  19. if (arriveMinutes > examMinutes)
  20. {
  21. //Late
  22. Console.WriteLine("Late");
  23. //за закъснение под час
  24. int late = arriveMinutes - examMinutes; //закъснение
  25. if(late < 60)
  26. {
  27. Console.WriteLine($"{late} minutes after the start");
  28. }
  29. else
  30. {
  31. int lateHour = late / 60;
  32. int lateMinute = late % 60;
  33. Console.WriteLine($"{lateHour}:{lateMinute:D2} hours after the start");
  34. }
  35. }
  36. else if (arriveMinutes == examMinutes || examMinutes - arriveMinutes <= 30)
  37. {
  38. //On time
  39. Console.WriteLine("On time");
  40. //точно на време -> не принтираме нищо допълнително
  41. // подраняваме с <= 30 мин -> принтираме с колко минути подраняваме
  42. if (examMinutes - arriveMinutes <= 30 && examMinutes != arriveMinutes)
  43. {
  44. Console.WriteLine($"{examMinutes - arriveMinutes} minutes before the start");
  45. }
  46. }
  47. else if (examMinutes - arriveMinutes > 30)
  48. {
  49. //Early
  50. Console.WriteLine("Early");
  51.  
  52. //подраняваме с по-малко от час
  53. int early = examMinutes - arriveMinutes; //подраняване
  54. if (early < 60)
  55. {
  56. Console.WriteLine($"{early} minutes before the start");
  57. }
  58. else //подраняване с 1 час или повече early >= 60
  59. {
  60. int earlyHour = early / 60;
  61. int earlyMinute = early % 60;
  62. Console.WriteLine($"{earlyHour}:{earlyMinute:D2} hours before the start");
  63. }
  64.  
  65.  
  66. }
  67. }
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement