There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer audio black screen boot bsod computer connection crash css dell display driver drivers email error excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop lcd linux malware network networking nvidia outlook outlook 2003 outlook express partition printer problem ram router slow sound trojan usb video virus vista windows windows vista windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Need help with a equation


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
Couriant's Avatar
Computer Specs
Distinguished Member with 23,506 posts.
 
Join Date: Mar 2002
Location: Proud Brit in VA
Experience: B.S. in M.I.S
16-Dec-2004, 09:21 PM #1
Need help with a equation
I don't know where to ask this but since it's part of my Programming Logic class i figured I can ask you

I need an equation to work out the total hours in a week that a person works.

I know that MOD and the \ operators are used but I just can't get my head around it. Any help will be appreciated
__________________
With the crime being eliminated in Hoosier Town, people are looking to come to our wonderful city. Please donate one click a day to fund their moving expenses!

A+ Certified, Network+ Certified

Marlene Porter aka. Angelize56 - July 21st 1956 to July 14th 2007
Rest in peace Angelcakes :*(
Elvandil's Avatar
Moderator with 29,452 posts.
 
Join Date: Aug 2003
Location: Vermont
16-Dec-2004, 09:32 PM #2
We could use a bit more information. This could be anything from Hopf Algebras to Modal Logic. What course is it, first of all? What are you trying to equate and what are the variables?
Couriant's Avatar
Computer Specs
Distinguished Member with 23,506 posts.
 
Join Date: Mar 2002
Location: Proud Brit in VA
Experience: B.S. in M.I.S
16-Dec-2004, 11:02 PM #3
Well that would help

I need to calcuate the total hours that an employee works. I would assume the variables would be AM_IN, AM_OUT, PM_IN and PM_OUT and the time would have to be in military time (obviously ) I thought that the equation would have been (AM_OUT-AM_IN)+(PM_OUT-PM_IN) but for an 8 hour day (say 0800 - 1230 and 1330 to 1700). HOURS variable is the total amount of hours in a day TOTAL_HOURS is another variable which will be all the hours calcuated for the week.

What i need is to work out the total hours in a week. (The value needs to be in 2 decimal places too)

I was looking at a loop to loop back to add in another timesheet. Then I need to calc all of the hours together. etc.

Hope this is understandable
__________________
With the crime being eliminated in Hoosier Town, people are looking to come to our wonderful city. Please donate one click a day to fund their moving expenses!

A+ Certified, Network+ Certified

Marlene Porter aka. Angelize56 - July 21st 1956 to July 14th 2007
Rest in peace Angelcakes :*(
Couriant's Avatar
Computer Specs
Distinguished Member with 23,506 posts.
 
Join Date: Mar 2002
Location: Proud Brit in VA
Experience: B.S. in M.I.S
18-Dec-2004, 09:41 PM #4
bump
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
19-Dec-2004, 12:23 PM #5
Do you have any code which you have tried? This is for a class.
Which programming language are you using?
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
19-Dec-2004, 01:23 PM #6
I use Visual Basic and so will show a quick example of how the datediff function can be used.

Code:
Private Sub Command1_Click()
Text1 = DateDiff("n", "10:00 am", "3:15 pm") / 60 & " hrs"

End Sub
This gives a nice clean result. This example uses minutes as the interval and then divides the result by 60 to get the hours worked.

5.25 hrs
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
19-Dec-2004, 01:39 PM #7
If you want to round off each interval to 2 decimal places then go a bit further like this:

Code:
Private Sub Command1_Click()
Dim M As Single
M = DateDiff("n", "10:01 am", "3:15 pm") / 60
Text1 = Format(M, "00.00") & " hrs"
End Sub
To get

05.23 hrs

This is just an example of getting the length and then formatting it. Using a text box is for convenience. You Likely not add the String "hrs" to the result or store it in a text box. But oif you did, reformat the results back to single to do math.


Also, how are the time cards formatted? There are a lot of ways to do this. The real trick is reading the daily information from the time card and doing the math.

How are you doing that?

Monday = 6.45
Tuesday = 3.25
Wednesday = 4.45


etc
Or like this.
Total = Total + M

M is each interval and gets added to a running total.


Or MMon could be Monday Morning work.

A could be afternoon. AMon = Mon Afternoon hours.
on and on for each day of the week.
These are just a few ideas.
Couriant's Avatar
Computer Specs
Distinguished Member with 23,506 posts.
 
Join Date: Mar 2002
Location: Proud Brit in VA
Experience: B.S. in M.I.S
20-Dec-2004, 01:14 AM #8
yeah uhh.. The 'class' is Programming Logic. We are not using a program persay, we need to do flowcharts and algorithms to show the modules READ, CALC and PRINT etc. We need to also show the calcuations in the flowcharts too. I have a file I did to show you what I mean. We covered the formula in a class where we done what I posted earlier like AM_OUT - AM_IN etc and then we used the MOD and \ functions, but I don't have any clue on how to use those. And now that the weather has turned bad I don't think school will be open today (monday).
Attached Files
File Type: doc Project.doc (36.5 KB, 34 views)
__________________
With the crime being eliminated in Hoosier Town, people are looking to come to our wonderful city. Please donate one click a day to fund their moving expenses!

A+ Certified, Network+ Certified

Marlene Porter aka. Angelize56 - July 21st 1956 to July 14th 2007
Rest in peace Angelcakes :*(
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
20-Dec-2004, 01:46 AM #9
I don't have Word installed and the word Viewer I used to use will not reinstall. Word Pad doesn't open your doc and show anything. Must be the graphics.
Couriant's Avatar
Computer Specs
Distinguished Member with 23,506 posts.
 
Join Date: Mar 2002
Location: Proud Brit in VA
Experience: B.S. in M.I.S
20-Dec-2004, 01:50 AM #10
try this
Attached Thumbnails
need-help-equation-flow.jpg  
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
20-Dec-2004, 01:59 AM #11
I know what a flowchart is. The problem you have is in Figuring out how many hours a person has worked. I am not sure what you need.

Sorry. It's very late here. Almost 2 am. I have to sign off.
Couriant's Avatar
Computer Specs
Distinguished Member with 23,506 posts.
 
Join Date: Mar 2002
Location: Proud Brit in VA
Experience: B.S. in M.I.S
20-Dec-2004, 02:05 AM #12
I hear ya, I'm on the same time zone. I was told that I could work out the hours by first calculating the minutes by doing the AM_IN etc and then using the MOD and \ function. If I can work that out then I can make a loop in it to do the rest of the weeks timesheet. I just need the calcuation... Man this is harder than I thought

OK, to make this as simple as I can make it. By typing in the time sheet, I need to calcuate the total hours an employee worked. The hours will be used to calcuate their pay for the week.

Need to go to bed.. me sleepy
__________________
With the crime being eliminated in Hoosier Town, people are looking to come to our wonderful city. Please donate one click a day to fund their moving expenses!

A+ Certified, Network+ Certified

Marlene Porter aka. Angelize56 - July 21st 1956 to July 14th 2007
Rest in peace Angelcakes :*(
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
20-Dec-2004, 02:36 AM #13
If we are playing at pseudo code then here, have fun
For each Day in Days
Hours worked = (AM_ OUT - AM_IN ) + (PM_OUT - PM_IN)
Total = Total + Hours Worked
Next
Couriant's Avatar
Computer Specs
Distinguished Member with 23,506 posts.
 
Join Date: Mar 2002
Location: Proud Brit in VA
Experience: B.S. in M.I.S
20-Dec-2004, 07:56 AM #14
I got that part, but how to I get the value into hours? Here is what would happen in that equation

800 = (1230-0800) + (1700-1330)

How do i get the hours from 800? See why its confusing me?
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
20-Dec-2004, 07:59 PM #15
Because you want decimals and time doesn't work that way. Not the minutes. There are 60 minutes in an hour. 1 min = 1/60th hour. 1 2/3 * minutes = percentage You'll see in a second.


Aren't time cards generally not in military hours? You would have to convert if you use this method. If PM then add 1200 to the PM entry. (Also this assumes it is not a midnight shift. If in at 10 pm and out at 2 am (Date Change) then we would need a different logic where we got the difference for start and then end from midnight and added together those differences.)

Are you not able to simulate the fact that most programming languages have a time function to figure this out? Ok I take it you want to use Mathematical operators to do this. You will have a bit of round off error. But here's the general gist. You want to get the hours and then convert the leftover minutes to decimal so 430 becomes 4.5 hrs. Correct?

Like this, if the worker worked from 7:30 am to 11:45 am
Difference = (1145 - 730) / 100
Hours = Difference Mod 100
Minutes = (Difference - Hours)

Finally Convert the minutes to decimal form.
Decimal Hours = Hours + (Minutes * 1.6666667)

The result is 4.25 hours worked. A lot of places have a majority rule. If you work 8 minutes, then that is counted 15. Less than 8 and that is 0. That avoids a lot of extra math.

Also, that picture you attached is causing a terrible scroll. If you get a chance, could you remove or resize it please? Thanks.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 04:43 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.