Advertisement
Alexander_B

Time Plus 15 Min

Jan 27th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 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 DomashnoTimePlus15Min
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. // get exact time
  14.  
  15. int HourNow = int.Parse(Console.ReadLine());
  16. int MinutesNow = int.Parse(Console.ReadLine());
  17.  
  18. // convert exact time to minutes
  19.  
  20. int MinutesAfterMidnight = HourNow * 60 + MinutesNow;
  21.  
  22. // add 15 min to converted
  23.  
  24. int MinutesAfterMidnight15MinLater = MinutesAfterMidnight + 15;
  25.  
  26. // calculate Hour after 15 min and convert if it is 24
  27.  
  28. int HourAfter15Min = MinutesAfterMidnight15MinLater / 60;
  29. if (HourAfter15Min == 24)
  30. {
  31. HourAfter15Min = 0;
  32. }
  33.  
  34.  
  35. // calculate minutes after 15 min
  36.  
  37. int MinutesAfter15Min = MinutesAfterMidnight15MinLater % 60;
  38.  
  39. // print if MinutesAfter15Min<10 with leading 0
  40.  
  41. if (MinutesAfter15Min < 10)
  42. {
  43. Console.WriteLine($"{HourAfter15Min}:0{MinutesAfter15Min}");
  44. }
  45. else
  46. {
  47. Console.WriteLine($"{HourAfter15Min}:{MinutesAfter15Min}");
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement