Add seconds, minutes and hours of two video clips

Challenge Level: Growing experience

Learning outcomes

Students will be able to:

Requirement:

Remix the program provided at https://scratch.mit.edu/projects/165770195/. Write a program that takes the durations of two video clips as the input (asks the user to enter the number of hours, minutes and seconds) and displays the total duration as the output. For example, for planning the length of clips in a film or songs in a playlist we might need to add the length of the first clip which is 32 minutes, 21 seconds (0:32:21) to the length of another clip which is 33 minutes and 20 seconds. Each time input (hours, minutes and seconds) are entered each on a different line. The output of your program should be 1 hour, 5 minutes and 41 seconds.

Testing examples:

Your program should display the outputs shown in this table for the given inputs provided;

Input Output
0:32:21
0:33:20

1:5:41
3:59:59
2:13:3

6:13:2
4:59:59
2:59:59

7:59:58

Languages

Scratch

What it should look like

Click on the green flag to see the expected output of your program.

Recommended blocks
when green flag clicked
set [secs1 v] to [0]

set [mins1 v] to [0]

set [hours1 v] to [0]

set [secs2 v] to [0]

set [mins2 v] to [0]

set [hours2 v] to [0]

set [total secs v] to [0]

set [total mins v] to [0]

set [total hours v] to [0]

set [hours1 v] to (answer)

set [mins1 v] to (answer)

set [secs1 v] to (answer)

set [hours2 v] to (answer)

set [mins2 v] to (answer)

set [secs2 v] to (answer)

set [total secs v] to ((secs1) + (secs2))

set [total mins v] to ((mins1) + (mins2))

set [total hours v] to ((hours1) + (hours2))

set [total secs v] to ((total secs) mod (60))

change [total mins v] by (1)

set [total mins v] to ((total mins) mod (60))

change [total hours v] by (1)
ask [Enter the number of hours for the first clip: ] and wait

ask [Enter the number of minutes for the first clip: ] and wait

ask [Enter the number of seconds for the first clip: ] and wait

ask [Enter the number of hours for the second clip: ] and wait

ask [Enter the number of minutes for the second clip: ] and wait

ask [Enter the number of seconds for the second clip: ] and wait
if <(total secs) > [59]> then
end

if <(total mins) > [59]> then
end
Hints
  • If total seconds (sum of the number of seconds from the first clip and the second clip) is greater than 59, increase total minutes (sum of minutes from the first clip and the second clip) by 1 and set total seconds to total seconds modulo 60.
  • If total minutes (sum of the number of minutes from the first clip and the second clip) is greater than 59, increase total hours (sum of hour from the first clip and the second clip) by 1 and set total minutes to total minutes modulo 60.

Show Scratch solution

Python