Advertisement
AJMitev

On Time for the Exam

Feb 7th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 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 Ontime_for_Exam
  8. {
  9. class ontime
  10. {
  11. static void Main(string[] args)
  12. {
  13. int examHours = int.Parse(Console.ReadLine());
  14. int examMinutes = int.Parse(Console.ReadLine());
  15. int ariveHours = int.Parse(Console.ReadLine());
  16. int ariveMinutes = int.Parse(Console.ReadLine());
  17.  
  18. int toMinutes = ((examHours * 60) + examMinutes) - ((ariveHours * 60) + ariveMinutes);
  19.  
  20. bool onTime = toMinutes == 0;
  21. bool inRange = toMinutes > 0 && toMinutes <= 30;
  22. bool late = toMinutes < 0;
  23. bool early = toMinutes > 30;
  24.  
  25. if (onTime)
  26. {
  27. Console.WriteLine("On time");
  28. }
  29. else if (inRange)
  30. {
  31. if (toMinutes > 59)
  32. {
  33. int hours = toMinutes / 60;
  34. int minutes = toMinutes % 60;
  35. Console.WriteLine($"On time\n{hours}:{minutes:00} hours before the start");
  36. }
  37. Console.WriteLine($"On time\n{toMinutes} minutes before the start");
  38. }
  39. else if (late)
  40. {
  41. toMinutes = Math.Abs(toMinutes);
  42. if (toMinutes > 59)
  43. {
  44. int hours = toMinutes / 60;
  45. int minutes = toMinutes % 60;
  46. Console.WriteLine($"Late\n{hours}:{minutes:00} hours after the start");
  47. }
  48. else
  49. {
  50. Console.WriteLine($"Late\n{toMinutes} minutes after the start");
  51. }
  52. }
  53. else if (early)
  54. {
  55. if (toMinutes > 59)
  56. {
  57. int hours = toMinutes / 60;
  58. int minutes = toMinutes % 60;
  59. Console.WriteLine($"Early\n{hours}:{minutes:00} hours before the start");
  60. }
  61. else
  62. {
  63. Console.WriteLine($"Early\n{toMinutes} minutes before the start");
  64. }
  65. }
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement