timecard calculator problem...

This is a discussion on timecard calculator problem... within the C Programming forums, part of the General Programming Boards category; Okay... pretty simple, but i just wanted verification, does this look right? I'll be implementing this into a command-line based ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Location
    pacific northwest
    Posts
    37

    timecard calculator problem...

    Okay... pretty simple, but i just wanted verification, does this look right?

    I'll be implementing this into a command-line based app, otherwise I'd use some spreadsheet or something.

    Code:
    Data
    
       x	in	09:25
    	out	13:14
    
       y	in	13:45
    	out	18:13
    
    Formula
    
       hours(x,y) = ((in[hour] * 60 + in[minute]) - (out[hour] * 60 + out[minute])) / 60
    
    Example
         
       x(3.42) = ((9 * 60 + 25) - (13 * 60 + 14)) / 60
       y(4.47) = ((13 * 60 + 45) - (18 * 60 + 13)) / 60
       z(7.89) = x + y
    "No, I am not wise, but I am a lover of wisdom." --Pythagoras

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    It seems to me the duration should be
    Code:
    {hours} = {out} - {in}
    rather than
    Code:
    {hours} = {in} - {out}
    Do you need to compensate for crossing a day boundary (that is, when you finish "before" you start)?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Timecard Challange
    By Thantos in forum Contests Board
    Replies: 2
    Last Post: 11-20-2003, 03:12 PM
  2. Console base timecard system
    By C-Dumbie in forum C Programming
    Replies: 7
    Last Post: 10-02-2002, 08:55 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21