StoimenK

C# 1.4 Back in 30 Minutes

Jan 20th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 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 _1._4_Back_in_30_Minutes
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. // Input --> Sirst line: hours ( 0 - 23 ) - Second line: minutes ( 0 - 59 )
  14. //Output --> format hh:mm. The hours have one or two numbers and the minutes have always two numbers (with leading zero).
  15.  
  16. int hours = int.Parse(Console.ReadLine());
  17. int minutes = int.Parse(Console.ReadLine());
  18.  
  19. minutes += 30;
  20.  
  21. if (minutes > 59)
  22. {
  23. hours += 1;
  24. minutes -= 60;
  25. }
  26. if ( hours > 23 )
  27. {
  28. hours = 0;
  29. }
  30.  
  31. Console.WriteLine($"{hours}:{minutes:D2}");
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment