I've been writing a program that calculates the hours and minutes between 2 military times.

For example the hours and minutes between 0900 and 1730; 1730 and 0900 the next day. Now I just converted all the times to seconds because I find that to be easier.

this is what I do..

hours for time 1 = time1 / 100

minutes for time 1 = time1 % 100

calculate total no of seconds = (hours * 3600) + (minutes * 60)

hours for time 2 = time2 / 100

minutes for time 2 = time2 % 100

calculate total no of seconds = (hours * 3600) + (minutes * 60)

Now this is where I have trouble.. I know I can do it with an if statement but we aren't allowed to use that yet...

remaining total seconds = seconds in 24 hours - abs((total num of secs for time 1 - total num of secs for time 2)

number of minutes = remaing total seconds / 60

number of hours = num of minutes / 60

minutes left over = number of minutes % 60

Then I output hours and minutes like 8 hours and 30 minutes

So if I take away the number of seconds in a day in this: remaining total seconds = seconds in 24 hours - abs((total num of secs for time 1 - total num of secs for time 2)

Then when I want to find the number of hours and minutes between 0900 -> 1730 I get 8 hours and 30 minutes which is correct.

But if I do 1730 -> 0900 the next morning I still get 8 hours 30 minutes.

And if I leaving the number of seconds in a day in I get the correct answer for 1730 -> 0900 but not for 0900 -> 1730.

I would appreciate any help you can give me this is a puzzle for me..