Respuesta :
Answer:
In Python:
hh = int(input("Hour: ")) * 3600
mm = int(input("Minutes: ")) * 60
ss = int(input("Seconds: "))
seconds = int(input("Additional Seconds: "))
time = hh+ mm + ss + seconds
hh = int(time/3600)
time = time - hh * 3600
mm = int(time/60)
ss = time - mm * 60
while(hh>24):
hh = hh - 24
print(str(hh)+" : "+str(mm)+" : "+str(ss))
Explanation:
We start by getting the time of the day. This is done using the next three lines
hh = int(input("Hour: ")) * 3600
mm = int(input("Minutes: ")) * 60
ss = int(input("Seconds: "))
Then, we get the additional seconds
seconds = int(input("Additional Seconds: "))
The new time is then calculated (in seconds)
time = hh+ mm + ss + seconds
This line extracts the hours from the calculated time (in seconds)
hh = int(time/3600)
time = time - hh * 3600
This line extracts the minutes from the calculated time (in seconds)
mm = int(time/60)
This line gets the remaining seconds
ss = time - mm * 60
The following iteration ensures that the hour is less than 24
while(hh>24):
hh = hh - 24
This prints the calculated time
print(str(hh)+" : "+str(mm)+" : "+str(ss))