Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,158 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,934 people online right now. Registration is fast and FREE... Join Now!




Hours worked in military time

 
Reply to this topicStart new topic

Hours worked in military time, need help with program

wowhesawesome
6 Dec, 2007 - 10:50 AM
Post #1

New D.I.C Head
*

Joined: 9 Nov, 2007
Posts: 14


My Contributions
I need to create a program to calculate hours worked when the user inputs a start time, then an end time. The thing i am not sure of however, is if you worked 2300 to 4 in the morning. I was possibly thinking an if statement could resolve this. like

if (end<start)
hours=

am i on the right track? any input is welcome!!!!
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Hours Worked In Military Time
6 Dec, 2007 - 12:25 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,199



Thanked: 213 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Since time moves forward, such an assumption could be made. The only way end time would be before start time is if end time was in the next day. Then you could do something like 2400 - start time + end time to get the time between the two.

2400 - 2300 = 100 + 400 = 5 hours.

That is how I would initially tackle it and see if it works out for various calculations. You can do this method since it is military time, 12hr clock would be a bit more tricky.

Hope that helps. smile.gif
User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 11:38PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month