← Back to Classes
Question 491
Add Minutes To The Clock
Add Minutes To The Clock
A Clock stores hours (0 to 23) and minutes (0 to 59). Write the body of add_minutes, which moves the clock forward by extra minutes: add extra to the stored minutes to get a total, move the hours on by total // 60 and wrap them with the remainder operator % 24, then set the minutes to the remainder of the total divided by 60. Do NOT write a main block or any top-level test code; the tests construct the class. Input: three lines, the hours, the minutes and the extra minutes, which the tests read as whole numbers; after calling your method they print the time as <hours> h <minutes> min.
Expected Output:
11 h 15 min= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
ClassesOperators
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.