Advertisement
IvanITD

03.TimeAnd15Minutes

Jan 15th, 2024
656
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | Source Code | 0 0
  1. int inputHours = int.Parse(Console.ReadLine());
  2. int inputMinutes = int.Parse(Console.ReadLine());
  3.  
  4. int hoursToMinuts = inputHours * 60;
  5.  
  6. int totalMinuteTime = hoursToMinuts + inputMinutes;
  7.  
  8. totalMinuteTime += 15; // The 15 minutes from the assigment
  9.  
  10. int hours = 0;
  11.  
  12. int minutes = totalMinuteTime % 60;
  13. hours = totalMinuteTime / 60;
  14.  
  15. if (hours == 24)
  16. {
  17.     hours = 0;
  18.    
  19.     if (minutes == 60)
  20.     {
  21.         hours++;
  22.         minutes = 0;
  23.     }
  24. }
  25.  
  26. Console.WriteLine($"{hours}:{minutes:D2}");
Tags: C#
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement