Need help on payroll report

This is a discussion on Need help on payroll report within the C Programming forums, part of the General Programming Boards category; I'm sort of stuck because I don't really know how the functions work here and how to actually READ the ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    5

    Question Need help on payroll report

    I'm sort of stuck because I don't really know how the functions work here and how to actually READ the input and output file..... Here is the general concept of the problem

    Many companies have a system where employees clock in and clock out to determine how much time they work each week. Since these records are already automatically stored in files on companies' computers, it only makes sense to use these files to help calculate how much each employee should get paid. In order to determine how much an employee gets paid each week, you need to know the following two pieces of information:

    1) The number of hours they worked in a week
    2) Their hourly pay rate

    If an employee works 40 or less hours a week, then they simply get paid the number of hours they worked times their hourly pay rate. If an employee works more than 40 hours, then they get paid an extra 50% of their regular pay for the hours over 40 they worked. (For example, if an employee's pay rate is $10/hour and the employee works 50 hours, then he/she would get paid $550, because he/she gets $10x50 = 500 normally, plus an extra .5x(10 hr)x($10/hr) = $50 for his/her overtime.


    Here's what i have so far,

    Code:
    #include <stdio.h>
    #define WEEK 10 
    
    int main()
    {
    FILE *ifp, *ofp;
    int Hr_in, Min_in, Hr_out, Min_out, Total_hr, num_empl;
    float pay_rate[EMPLOYEES];
    float total_time, pay;
    char [WEEK];
    
    
    ifp=fopen("clock.txt", "r");
    ofp=fopen("payroll.txt", "w");
    
    
    fscanf(ifp, "%d", &num_empl);
    fprintf(ofp, Number of employees:"%d\n", num_empl);
    for (index=0; index<num_empl; index++) 
    { 
    	scanf(outfptr, "%f", pay_rate[index]);
    	
    }
    
    
    
    
    return 0;
    
    }

    I know it's not much, but i'm TOTALLY confused by the input file, which is..

    2
    5.15
    10.00
    5
    1 9 0 13 45
    0 10 50 18 10
    0 7 30 13 30
    1 8 30 18 50
    0 12 20 13 20
    4
    1 8 0 18 0
    1 8 0 19 0
    1 8 0 19 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0

    OUTPUT:

    Number of employees: 2

    Week 1
    EmpID Hrs Pay
    0 14.33 73.82
    1 15.08 150.83

    Week 2
    EmpID Hrs Pay
    0 0.00 0.00
    1 44.00 460.00

    Week 3
    EmpID Hrs Pay
    0 5.00 25.75
    1 12.00 120.00

    Week 4
    EmpID Hrs Pay
    0 5.00 25.75
    1 12.00 120.00

    Week 5
    EmpID Hrs Pay
    0 5.00 25.75
    1 12.00 120.00

    Week 6
    EmpID Hrs Pay
    0 5.00 25.75
    1 12.00 120.00

    Week 7
    EmpID Hrs Pay
    0 5.00 25.75
    1 12.00 120.00

    Week 8
    EmpID Hrs Pay
    0 5.00 25.75
    1 12.00 120.00

    Week 9
    EmpID Hrs Pay
    0 5.00 25.75
    1 12.00 120.00

    Week 10
    EmpID Hrs Pay
    0 5.00 25.75
    1 12.00 120.00

    Total
    EmpID Hrs Pay
    0 54.33 279.82
    1 155.08 1570.83



    any suggestions would help, and I know this is sort of long for you people to read

    THANX VERY MUCH

  2. #2
    Registered User
    Join Date
    Jan 2006
    Location
    Berkeley, Ca
    Posts
    195
    Eeeeeeeeeewwwwwwwwwww....... Numbers. Okay, looking at the output data, I can infer a few things.

    When I divide employee ID 0 pay by their hours, I get 5.15
    When I divide employee ID 1 pay by their hours, I get 10.00

    This gives us the pay rate.

    Looking at the input file

    The lines
    2
    5.15
    10.00

    Suggests that this holds the employees pay rate information.

    Also looking at the output file, the 2,4,5 seem to indicate the number of lines.

  3. #3
    Registered User
    Join Date
    Jan 2006
    Location
    Berkeley, Ca
    Posts
    195
    Okay, I need to cut this short and do something productive and go shoe shopping. Anyhow, I do see a general pattern in the numbers.

    If you start here
    5
    1 9 0 13 45
    0 10 50 18 10
    0 7 30 13 30
    1 8 30 18 50
    0 12 20 13 20

    And count each block, it adds up to 10. This means each block represents on week. The 5 in this case indicates the number of days (or lines) the employee works. I'm going to use the simple one.

    4
    1 8 0 18 0
    1 8 0 19 0
    1 8 0 19 0
    1 8 0 20 0

    This is the field for week 2. The first number is the seems to be the employee id number. There are 4 lines which would mean employee 1 worked 4 days, but employee 2 didnt work at all. Looking at the corresponding output, we have

    Week 2
    EmpID Hrs Pay
    0 0.00 0.00
    1 44.00 460.00

    The hours for employee 1 are 44. Now go down each line and subtract 18 from 8, then the 19 from 8, then the 19 from 8 and then the 20 from 8. This adds up to 44. Now go down each block and you will see this adds up to the corresponding hours. I'm not too sure what the significance of the zero between the numbers are.
    Last edited by cdalten; 04-08-2006 at 02:40 PM.

  4. #4
    Registered User
    Join Date
    Feb 2006
    Posts
    32
    Quote Originally Posted by cdalten
    Thanks for clarifying what I've already explained. Glad to see reading is still alive in this day and age.
    Main Entry: conĚcise
    Pronunciation: k&n-'sIs
    Function: adjective
    Etymology: Latin concisus, from past participle of concidere to cut up, from com- + caedere to cut, strike
    1 : marked by brevity of expression or statement : free from all elaboration and superfluous detail
    2 : cut short : BRIEF
    (Courtesy of m-w.com)

    I read your post but I was only trying to present the sparknotes version, which as you know alot of people are more likely to read versus the actual book.

    I guess what I should have said was...

    "AIM: iiwhitexb0iii with specific questions and I'd be glad to spend some time helping you out."
    Last edited by iiwhitexb0iii; 04-08-2006 at 08:12 PM.

  5. #5
    Registered User
    Join Date
    Jan 2006
    Location
    Berkeley, Ca
    Posts
    195
    Quote Originally Posted by iiwhitexb0iii
    2 //number of employees
    5.15 //pay rate employee 0
    10.00 //pay rate employee 1
    5 //entries per week
    1 9 0 13 45 //employee number, hrIn, minIn, hrOut, minOut
    0 10 50 18 10
    0 7 30 13 30
    1 8 30 18 50
    0 12 20 13 20
    4
    1 8 0 18 0
    1 8 0 19 0
    1 8 0 19 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0
    2
    0 10 0 15 0
    1 8 0 20 0

    ten weeks total on your input sheet

    hope this helped
    Thanks for clarifying what I've already explained. Glad to see reading is still alive in this day and age.

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Hmmm....

    http://www.youngcoders.com/thread17943.html


    Maybe someone will help eventually if you post around enough.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Report from Some Text Boxes ??
    By _root in forum C# Programming
    Replies: 1
    Last Post: 05-22-2009, 03:59 AM
  2. Replies: 2
    Last Post: 05-13-2009, 12:57 PM
  3. Moving Average Question
    By GCNDoug in forum C Programming
    Replies: 4
    Last Post: 04-23-2007, 11:05 PM
  4. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 12:05 PM

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