Alarm timer
Hi all! Tell me what is the error?
The number n is given. n minutes have passed since the beginning of the night. Determine how many hours and minutes the digital clock will show at the moment. The program should output two numbers: the number of hours (from 0 to 23) and the number of minutes (from 0 to 59). Please note that n can be greater than the number of minutes in a day.
6 Replies
The modulo 12 calculation is probably the problem. The instructions specifically state that the hours can range from 0 to 23, which is European/military time. The modulo 12 is only for AM/PM time. It should be modulo 24.
I think it shouldn't be used at all. The instructions specify that only two numbers should be used, representing hours and minutes. If n is greater than several days, it's irrelevant since the problem doesn't ask for days.
also, it helps if you share your code in plain text instead of as a screenshot. It lets people run the code for themselves if they want to
The problem is that when I enter 24, the timer does not display the correct one and the result does not pass the code validity test, but it does not pass with my code, although the results were the same
With modulo 24 it should work. You don't even need the if statement, just add it to where you calc the hours
Math.floor(n/60) % 24
If that doesn't work, please show the test and result (can be a schreenshot)Thank you very much everything works, he cursed at if