Pretorianbg

Untitled

Oct 2nd, 2018
709
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 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. double examhour = double.Parse(Console.ReadLine());
  14. double examminutes = double.Parse(Console.ReadLine());
  15. double arrivalhour = double.Parse(Console.ReadLine());
  16. double arrivalminutes = double.Parse(Console.ReadLine());
  17.  
  18. double examtime = examhour * 60 + examminutes;
  19. double arrivaltime = arrivalhour * 60 + arrivalminutes;
  20. double diff = examtime - arrivaltime;
  21. double hours = 0;
  22. double minutes = 0;
  23.  
  24. if (diff <= -1) Console.WriteLine("Late");
  25. else if (diff>=0 && diff <= 30) Console.WriteLine("On Time");
  26. else if (diff > 30) Console.WriteLine("Early");
  27.  
  28.  
  29. if (diff > 0 && diff < 60)
  30. Console.WriteLine($"{diff} minutes before the start");
  31.  
  32. else if (diff >= 60)
  33. {
  34.  
  35. hours = Math.Truncate(diff / 60);
  36. minutes = Math.Abs(diff % 60);
  37. if (minutes < 10) Console.WriteLine($"{hours}:0{minutes} hours before the start");
  38. else Console.WriteLine($"{hours}:{minutes} hours before the start");
  39. }
  40.  
  41. else if (diff < 0 && diff >= -59)
  42. Console.WriteLine($"{Math.Abs(diff)} minutes after the start");
  43.  
  44. else if (diff <-60)
  45. {
  46.  
  47. hours = Math.Abs(Math.Truncate(diff / 60));
  48. minutes = Math.Abs(diff % 60);
  49. if (minutes < 10) Console.WriteLine($"{hours}:0{minutes} hours after the start");
  50. else Console.WriteLine($"{hours}:{minutes} hours after the start");
  51. }
  52.  
  53. }
  54. }
  55. }
Add Comment
Please, Sign In to add comment