Coding Challenge: Adding seconds to time

Learn how to write a program that asks for a time in the form of hours, minutes, and seconds.

Problem statement

Write a program that asks for a time under the form of three information (hours, minutes, seconds). The program calculates and shows the time one second after. Incorrect inputs must be taken into account.

This is not as simple as it seems… Look at the following results to see for yourself:

Input

Enter the hours: 14
Enter the minutes: 17
Enter the seconds: 59

Expected output

In a second, time will be 14 hours, 18 minutes, and 0 seconds.

Coding exercise

Get hands-on with 1200+ tech skills courses.