Answer:
The program in Python is as follows:
cTime = int(input("Current Hour: "))
while(cTime <1 ):
cTime = int(input("Current Hour: "))
aTime = int(input("Additional Hours: "))
while(aTime <0):
aTime = int(input("Current Hour: "))
tTime = cTime + aTime
tTime%=12
print("New:",tTime,"hours")
Explanation:
This gets input for current time
cTime = int(input("Current Hour: "))
The following ensures that the user enters a time greater than 0
while(cTime <1 ):
cTime = int(input("Current Hour: "))
This gets input for additional time
aTime = int(input("Additional Hours: "))
The following ensures that the user enters a positive time
<em>while(aTime <0):</em>
<em> aTime = int(input("Current Hour: "))</em>
This calculate the new hours
tTime = cTime + aTime
This gets the hour equivalent between 1 and 12
tTime%=12
This prints the new hour
print("New:",tTime,"hours")