Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ExamSchedule
- {
- public class Program
- {
- public static void Main()
- {
- int hours = int.Parse(Console.ReadLine());
- int minutes = int.Parse(Console.ReadLine());
- string dayPart = Console.ReadLine();
- int hoursAdded = int.Parse(Console.ReadLine());
- int minutesAdded = int.Parse(Console.ReadLine());
- int result = (hours + hoursAdded) * 60 + minutes + minutesAdded;
- int totalHours = result / 60 % 24;
- int totalMinutes = result % 60;
- dayPart = totalHours >= 12 ? (dayPart == "AM" ? "PM" : "AM") : dayPart;
- totalHours -= totalHours > 12 ? 12 : 0;
- Console.WriteLine($"{totalHours:d2}:{totalMinutes:d2}:{dayPart}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement