Clock Hands double The current position of the hour hand dou

Clock Hands (double) The current position of the hour hand (double) The current position of the minute hand (double) A positive or negative number of minutes (double) The position of the hour hand after the specified time (double) The position of the minute hand after the specified time It is not always immediately obvious where the hands of a clock will be after a certain amount of time It is even harder to visualize where the hands were some amount of time in the past Luckily, this is not a very difficult problem for a computer to solve, so you will use that to your advantage This function will take in the current position of the hour hand, as an integer between 0 and 11. inclusive (0 for noon/midnight) and the current position of the minute hand, as an integer between 0 and 59. inclusive (0 for \'\'on - the - hour\') and a positive or negative number of minutes elapsed. Given this information, calculate the new position of the clock hands You should assume that the hour hand does not move until the next hour has begun For example, the hour hand stays on \'2\' from 2:00 until 2:59 and only at 3:00 does the hour hand move to \'3\'. The mod() and floor() functions will be useful. As you do this problem notice the behavior of mod() for negative inputs This is a very important function in programming and will come up again in the class! One way of solving this problem involves calculating the total number of minutes after noon/midnight before and after the given minutes have elapsed. Another way of solving it involves splitting the given number of minutes into a number of hours and a number of minutes. Pick whichever method makes more sense to you (or come up with your own method).

Solution

x = current position of hour

y = current position of minute

d = difference in minutes

the function will return

position of hour = mod(floor((y + d)/60) + x,12)
position of minute = mod((y + d),60)

 Clock Hands (double) The current position of the hour hand (double) The current position of the minute hand (double) A positive or negative number of minutes (

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site