Help with Program, Pay C++

Discussion in 'C++' started by tyranthacker, Oct 28, 2010.

  1. tyranthacker

    tyranthacker New Member

    Joined:
    Oct 28, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    I need help writing this program for C++, Needs to be written in basic C++. I can pay with paypal but here is the description:

    A program that will process the time clock information and report the amount of money an employee has earned.

    In the first phase, you will read from the keyboard and write to the screen. In Phase II you will change this to read from a file.

    Phase I

    Here's an example of the interaction with the user. The user types in the name, the start and stop times and the payrate.

    Time Clock Program

    Enter worker name: John Q. Smith
    Enter start time (hh:mm A/P): 8:30 A
    Enter stop time (hh:mm A/P): 3:30 P
    Enter pay rate: 5.25

    Employee John Q. Smith has worked 7.00 hours
    No overtime
    The paycheck is for $36.75
    Here's another example of the interaction with the user.

    Time Clock Program

    Enter worker name: Bob Brown
    Enter start time (hh:mm A/P): 8:50 A
    Enter stop time (hh:mm A/P): 11:10 p
    Enter pay rate: 7.25

    Employee Bob Brown has worked 14.33 hours
    6.33 hours overtime
    The paycheck is for $126.87
    A new sample with bad times

    Time Clock Program

    Enter worker name: John Q. Smith
    Enter start time (hh:mm A/P): 8:90 A
    Enter stop time (hh:mm A/P): 3:30 X
    Enter pay rate: 5.25

    Invalid time! Time set to 0:00
    Invalid time! Time set to 0:00

    Employee John Q. Smith has worked 0.00 hours
    No overtime
    The paycheck is for $0.00


    A "time value" is formatted as:

    First there is an integer from 1 to 12, then a colon :)) then another integer from 0 to 59, then possibly one or more spaces then one letter which should be A or P or a or p.
    Remember that 12:00 A is midnight, 12:00 P is noon.
    Your program should validate the input before trying to process it. This means that a starting time that comes after an ending time should be reported. So your program can assume that the employee does not work more than 24 hours. So if the start time is AM, the end time could be AM or PM, if the start time is PM, the end time should be PM also. It should check for badly formed times, like 13:00 A or 12:89 P or 12:00 X.

    Overtime pay is given at "time-and-a-half" rates (1.5 times the normal pay rate) if the employee works more than 8 hours. The program should be written so that this value (8) would be easy to change.

    You can certainly use manipulators to format the output. Note that if a time has a value like 12:00, that two zeros for the minutes are printed out. This should happen for all minute values from 00 up to 09. You may NOT use "setfill".

    Phase II

    Now change your program to ask the user for the name of a data file and then read the data from the file.

    The name of the file to be tested will be supplied by the user. If the file won't open, the user should be informed, the program should beep and then abort.

    The format of the time clock data file is:

    one string on a line, which is an employee's name. It may have spaces and it will be delimited by a newline.
    On the next line, there will be a time value representing the time the employee started working.
    On the next line, there will be a time value representing the time the employee stopped working.
    On the next line, there will be a floating point number that is the pay rate for that employee per hour.
    There may be extraneous (extra) information on any of the lines with numbers on them.
    Here is an example of the interaction between the user and your program. All the user enters is the filename. The rest is output echoing the data in the file and then the calculated results.

    Time Clock Program
    Enter the filename of data to process --> timedata1

    Name: John Smith
    Start time 8:50 A
    Stop time 11:25 A
    Pay rate $3.25 per hour

    The employee John Smith has worked 2.58 hours
    No overtime
    The paycheck is for $8.40
    The input file timedata1 contains:

    John Smith
    8:50A
    11:25 A
    3.25
    Here is another example of the interaction between the user and your program.

    Time Clock Program
    Enter the filename of data to process --> timedata2.dat

    Name: Ralph Johnson
    Start time 8:00 A
    Stop time 9:00 P
    Pay rate $4.00 per hour

    The employee Ralph Johnson has worked 13.00 hours
    5.00 hours overtime
    The paycheck is for $62.00
    The input file timedata2.dat contains:

    Ralph Johnson
    8:00 A
    9:00 P
    4
    Here is another example of the interaction between the user and your program.

    Time Clock Program
    Enter the filename of data to process --> junkdata

    Sorry, that file does not exist! {beep}
    Program is aborting.
    And no other output is created.

    Here is another example of the interaction between the user and your program.

    Time Clock Program
    Enter the filename of data to process --> timedata3

    Name : Don Brown
    Start time 8:30 P
    Stop time 7:30 P
    Pay rate $5.00 per hour
    Times are out of order!

    The employee Don Brown has worked 0.00 hours
    No overtime
    The paycheck is for $0.00
    The input file timedata3 contains:

    Don Brown
    8:30 P
    7:30 P
    5.00
     
  2. tyranthacker

    tyranthacker New Member

    Joined:
    Oct 28, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Delete this post please
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Without a reason we normally do not delete posts. Any reason why you want it to be deleted.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice