Working out what time is 3 hours and 40 minutes later than 11:45 a.m. is not very difficult, but is quite easy to get wrong when worked out in a hurry. For this problem you have to write a program that performs calculations of exactly that kind.
Your program will receive as input a time (in the usual hours and minutes form, using the 12 hour clock), a + or - sign to indicate whether it is to add or subtract an interval, and an interval expressed in hours and minutes. The output should simply be the new time.
Take care to keep the hours between 1 and 12. You do not need to be worried about the difference between a.m. and p.m.: 20 minutes earlier than 12:10 is 11:50; 12 hours later than 12:10 is 12:10.
The input to your program will consist of a number of lines, each line containing the following:
If the sign is a -, the hours and minutes are both to be subtracted - be careful not to accidentally add the minutes. 2:20 minus 1:05 should be 1:15.
The end of the input will be signalled by a line containing "0 0 + 0 0". This is not an input to be processed, it is simply a marker for the end of the inputs.
For each input case print a single line containing the resultant time in the traditional format: the hours in one or two digits, then a colon, then the minutes always in two digits. No spaces anywhere.
Take care when the minutes component is small. "five minutes past two" should be printed as 2:05, not 2:5.
12 10 - 0 20 5 22 - 7 31 4 13 + 0 0 9 30 + 6 0 0 0 + 0 0
11:50 9:51 4:13 3:30