Seconds in a day

Seconds in a day

Convert seconds to hours and minutes.

The number of seconds can also be expressed in hours and minutes.

Make


Write a program that allows the user to enter the number of seconds. The program outputs the number of equivalent hours, minutes and seconds that is.

Use this boilerplate code as a starting point:

Success Criteria

Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.

Complete the subprogram called `seconds_to_hours` that:

  1. Returns the number of hours calculated as seconds integer divided by three thousand six hundred.

Complete the subprogram called `seconds_to_minutes` that:

  1. Returns the number of minutes calculated as seconds integer divided by sixty, modulo sixty.

Complete the subprogram called `seconds_remaining` that:

  1. Returns the modulo of seconds by sixty.

Complete the `main program` so that:

  1. The user can input the number of seconds.
  2. It outputs the number of seconds in hours, minutes and seconds.

Typical inputs and outputs from the program would be:

Enter the number of seconds: 60

0 hours 1 minutes 0 seconds


Enter the number of seconds: 1460

0 hours 24 minutes 20 seconds


Enter the number of seconds: 86000

23 hours 53 minutes 20 seconds


Enter the number of seconds: 4200

1 hours 10 minutes 0 seconds

Knowledge Organiser

Use these resources as a reference to help you meet the success criteria.

Programming guide:

Evaluate


Run the unit tests below to check that your program has met the success criteria.

Enter the number of seconds: 42

0 hours 0 minutes 42 seconds

Enter the number of seconds: 120

0 hours 2 minutes 0 seconds

Enter the number of seconds: 3600

1 hours 0 minutes 0 seconds

Enter the number of seconds: 65853

18 hours 17 minutes 33 seconds

Check that you have:

  • Used comments within the code to describe the purpose of subprograms, conditions and iterations.
  • Used meaningful identifier names. That means the names of subprograms and variables indicate what they are for.
Craig'n'Dave logo

Craig ‘n’ Dave

In partnership with

Mission Encodeable
Bett Awards 2024 Finalist