Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _01.Exam_Schedule
- {
- class Exam_Schedule
- {
- static void Main(string[] args)
- {
- int startingHour = int.Parse(Console.ReadLine());
- int startingMinutes = int.Parse(Console.ReadLine());
- string amPmDesignator = Console.ReadLine();
- int durationHours = int.Parse(Console.ReadLine());
- int durationMinutes = int.Parse(Console.ReadLine());
- int allMunutes = startingHour * 60 + startingMinutes + durationHours * 60 + durationMinutes;
- int hours = allMunutes / 60;
- int minutes = allMunutes % 60;
- if (hours >= 12 && amPmDesignator == "AM")
- {
- hours -= 12;
- if (hours == 0)
- {
- hours = 12;
- }
- amPmDesignator = "PM";
- }
- else if (hours >= 12 && amPmDesignator == "PM")
- {
- hours -= 12;
- if (hours == 0)
- {
- hours = 12;
- }
- amPmDesignator = "AM";
- }
- string formattedTime =
- string.Format("{0}:{1}:{2}", hours.ToString().PadLeft(2, '0'), minutes.ToString().PadLeft(2, '0'), amPmDesignator);
- Console.WriteLine(formattedTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement