Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 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 On_Time_for_the_Exam
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int hoursExam = int.Parse(Console.ReadLine());
  14. int minutesExam = int.Parse(Console.ReadLine());
  15. int hoursArrive = int.Parse(Console.ReadLine());
  16. int minutesArrive = int.Parse(Console.ReadLine());
  17.  
  18. var timeExam = hoursExam * 60 + minutesExam;
  19. var timeArrive = hoursArrive * 60 + minutesArrive;
  20. var timeDiff = Math.Abs(timeExam - timeArrive);
  21. var hourDiff = timeDiff / 60;
  22. var minutesDiff = timeDiff % 60;
  23.  
  24. if (timeArrive > timeExam)
  25. {
  26. Console.WriteLine("Late");
  27. if (timeDiff < 60)
  28. { Console.WriteLine("{0} minutes after the start", timeDiff); }
  29.  
  30. else
  31. { Console.WriteLine("{0}:{1:D2} hours after the start", hourDiff, minutesDiff); }
  32. }
  33.  
  34.  
  35. else if ((timeExam - timeArrive) >= 0 && (timeExam - timeArrive) <= 30)
  36. {
  37. Console.WriteLine("On time");
  38. Console.WriteLine("{0} minutes before the start", timeDiff);
  39. }
  40.  
  41.  
  42. else if ((timeExam - timeArrive) > 30)
  43. {
  44. Console.WriteLine("Early");
  45.  
  46. if (timeDiff < 60)
  47. { Console.WriteLine("{0} minutes before the start", timeDiff); }
  48.  
  49. else
  50. { Console.WriteLine("{0}:{1:D2} hours before the start", hourDiff, minutesDiff); }
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement