Advertisement
Guest User

Untitled

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