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
whenclicked
setsecs1to0setmins1to0sethours1to0setsecs2to0setmins2to0sethours2to0settotal secsto0settotal minsto0settotal hoursto0sethours1toanswersetmins1toanswersetsecs1toanswersethours2toanswersetmins2toanswersetsecs2toanswersettotal secstosecs1+secs2settotal minstomins1+mins2settotal hourstohours1+hours2settotal secstototalsecsmod60changetotal minsby1settotal minstototalminsmod60changetotal hoursby1
askEnter the number of hours for the first clip: andwaitaskEnter the number of minutes for the first clip: andwaitaskEnter the number of seconds for the first clip: andwaitaskEnter the number of hours for the second clip: andwaitaskEnter the number of minutes for the second clip: andwaitaskEnter the number of seconds for the second clip: andwait
iftotalsecs>59theniftotalmins>59then
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