Hello I need some assistance in writing this code out, basically I will take a user inputted number divided by 3 + 180 then the output will be in hours and minutes..example 72 would be 1 hour 12 minutes. Here's my current code but I can't get it to work. <!DOCTYPE html> <html> <body> <script> var pets = prompt ("How many pets do you own?"); Function GetTime() { Math.floor(180 + pets/60) +" Hour "+ pets%60 + " Minutes."; } document.write GetTime; </script> </body> </html> Code (markup):
1) It looks like your code is producing 181 hours and 12 minutes, which is not even close to what you are looking for. 2) I do not see anywhere that you are dividing by 3 3) Your example will never produce the results you are looking for pets = 72/3 + 180 INT(pets)/60 = 3 hours MOD(pets, 60) = 24 minutes
If you want to convert minutes to hours and minutes, you can use something like this: function convert_time(number) { var hours = Math.floor(number / 60); var minutes = number % 60; return hours + ":" + minutes; } Code (JavaScript):
Duh, didn't you READ what the OP said? That is the formula he is using! He needs help with the INPUTS, not the FORMULA.