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 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 second it will take to complete the task (greater than ) 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 (ie, at least one minute), the current second value is updated to 2. The minuto 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 I because minute rolled over from 59 to 60 and then too. This produces the final result of 3.0 and 2 for hour, minute and second, respectively. The return value of the function is in string given in this format him , where h gives the updated hour, gives the updated minute, and a 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 zeros will be marked as incorrect Function Arguments Return Value 2, 59, 40, 22 "3:0:21 5, 11, 24, 6 5:11:30! 4, 11, 25, 236 14:15:21: 11, 54, 56, 340 '12:0:36 22, 52, 48, 8000 11:6:81 17, 17, 5, 31688 2:5:13 19, 6, 53, 7500 21:11:53 20, 34, 35, 26770 14:0:451 19, 54, 3, 15463 10:11:46' 18, 21, 35, 26875 11: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

Sql All In One For Dummies 7 Books In One

Authors: Allen G Taylor ,Richard Blum

4th Edition

1394242298, 978-1394242290

More Books

Students also viewed these Databases questions