Advertisement
Guest User

03. On Time for the Exam

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