C
C#3y ago
TOLOXI

Need help with a simple program

im trying to code a progra mthat converts minutes to hours. but the module thingy is doing the oppsisite of wha its supposed to do
7 Replies
Grault
Grault3y ago
I think you want minuer / 60.
TOLOXI
TOLOXIOP3y ago
im supposed to use a module and if i used a / it wont give me the remaining minutes
Grault
Grault3y ago
If the time is 18:30, and you have that as a number of minutes since midnight, minuer / 60 == 18 and minuer % 60 == 30.
TOLOXI
TOLOXIOP3y ago
but all i wanna do is convert minutes to hours so 150 minutes would be 2 hours and 20 minutes
Grault
Grault3y ago
/ 60 will do that.
TOLOXI
TOLOXIOP3y ago
ill try that it works if i convert it to a double but is there a way to reverse a module? have it do the oppisite of what it does
Grault
Grault3y ago
18 * 60 + 30 In my example above, that will get the original number of minutes since midnight. Or maybe you mean you want (in your example of 2 hours and 20 minutes) f(140) = 40. That would be f(x) = 60 - (x % 60). That's the number of minutes until the end of the hour.

Did you find this page helpful?