Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part IV: Determine the Ending Time (25 points) Write a function ending-time () that determines the final clock time after a task has been completed.

image text in transcribed

image text in transcribedimage text in transcribed

Part IV: Determine the Ending Time (25 points) Write a function ending-time () that determines the final clock time after a task has been completed. The function takes three arguments that provide the current time of day, as well as the total time in seconds that it will take to complete the task: 1. hour: the current hour of the day (0 23) 2. minute: the current minute of the day (0 59) 3. second: the current second of the day (0 - 59) 4. time_taken: the number of seconds it will take to complete the task (greater than 0) You may assume that the four input values are always valid. As an example of what this function computes, consider the test case: 2, 59, 40, 22. This means that the current hour is 2, the current minute is 59, the current second is 40, and the time to complete the task is 22 seconds. So the first three function arguments represent the time 2:59:40 am. Adding time_taken to the current second value updates the second value to 62. Because 62 seconds is > 60 (i.e., at least one minute), the current second value is updated to 2. The minute value must also be incremented by 1 minute, to 60. Similar to how we handled the second value, the minute is set to zero because we have a whole new hour. Finally, the hour value must be incremented by 1 because minute rolled over from 59 to 60 and then to 0. This produces the final result of 3, 0, and 2 for hour, minute and second, respectively. The return value of the function is an f-string given in this format: 'h:m:s', where h gives the updated hour, m gives the updated minute, and s gives the updated second. To keep things simple the returned string should not include leading zeroes. As an example, if the new values for hour, minute and second are 5, 9 and 2, the returned value should simply be the string '5:9:2', not '05:09:02'. Answers that contain leading zeroes will be marked as incorrect. Examples: Function Arguments 2, 59, 40, 22 5, 11, 24, 6 4, 11, 25, 236 11, 54, 56, 340 22, 52, 48, 8000 17, 17, 5, 31688 19, 6, 53, 7500 20, 34, 35, 26770 19, 54, 3, 15463 18, 21, 35, 26875 Return Value 3:0:2' 5:11:30' 4:15:21' '12:0:36 '1:6:8' '2:5:13' 21:11:53' '4:0:45' '0:11:46' '1:49:30

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions