+ 1

Hello, Can anyone help with how i can fit in the modulus operator in this code

I was working on an exercise from thinkjava that converts total seconds to hours, minutes, seconds. Hint given says to use the modulus operator. But i quite cant fit it in I did manage to make code work though without the modulus But i want to know how the modulus would fit in https://code.sololearn.com/ce2BOjSBxf68/?ref=app

15th Apr 2020, 12:55 PM
Bamgboye Oluwatosin
Bamgboye Oluwatosin - avatar
3 Réponses
0
Hello Bamgboye Oluwatosin 1 hour = 3600 s; 1 min = 60 s; input = 7833 s; Get the hours: hours = input / 3600 hours = 7833 / 3600 = 2 Now you need to know how many seconds remains: rest = input % 3600 rest = 7833 % 3600 = 633; Get the minutes: min = rest / 60 min = 633 / 60 = 10; And again, calculate the seconds which remains: rest = rest % 60 rest = 633 % 60 = 33 7833s = 02:10:33
15th Apr 2020, 7:26 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Ah, simple math problem Couldnt see it b4 but i get it now Thanks Denise Roßberg
15th Apr 2020, 8:01 PM
Bamgboye Oluwatosin
Bamgboye Oluwatosin - avatar
0
Bamgboye Oluwatosin Your welcome :)
15th Apr 2020, 8:08 PM
Denise Roßberg
Denise Roßberg - avatar