Assignment #15 (50 Points) Use Composition to implement the following: Use Multiple Source file, Class Definition in hea
Posted: Sun May 15, 2022 1:13 pm
Assignment #15
(50 Points)
Use Composition to implement the following:
Use Multiple Source file, Class Definition in header file, class
implementation in .cpp file and application in separate .cpp
file.
Not using these criterias will receive 0 for the points.
Design a TimeCard class that allows a
company to pay a worker for a day’s labor.
The worker uses the time card to punch in at the beginning of the
day and punch out upon quitting.
The company immediately pays the worker based on the hourly rate
and the length of time on the job.
Use composition and incorporate
the Time2 class to keep track of
the
punchInTime (start time)
and punchOutTime (end time) in
the TimeCard class.
Use the following fields as private data for
the Time2:
private int hour;
private int minute;
private int second;
Create all the appropriate method and constructors, with validation
criteria.
Use the following fields as private data for
the TimeCard:
Use the following fields as private data for
the TimeCard:
private string
workerID;
// SS Number
private Time2 punchInTime, punchOutTime; // Time2 objects
private double
payrate;
// hourly pay
private bool
hasPunched;
// set to true after worker punches out
Write a test program that will create
a punchInTime object and
a punchOutTime object.
The class TimeCard should have member
function(s) to calculate the duration (hours worked)
and calculate and print the day’s earnings.
Assume no worker punches in before 8:00 AM and no worker punches
out after 5:00 PM (17.00).
Sample Input/Output:
Worker ID: 123456789
Start Time: 8:00:00 AM
End Time: 3:30:00 PM
Pay Rate: $12.50
Hours worked: 7.50
Per hour, the day's earnings are: $93.75
Worker ID: 997654321
Start Time: 8:00:00 AM
End Time: 4:30:00 PM
Pay Rate: $12.50
Hours worked: 8.50
Per hour, the day's earnings are: $106.25
Table format would be more usable.
Worker
ID
Start Time End Time
Pay Rate Hours Worked
Day's Earning
123456789
8:00:00 AM
3:30:00 PM $12.50
7.50
$ 93.75
997654321
8:00:00 AM 4:30:00 PM
$12.50
8.50
$106.25
In order to get the full point for the assignment, make sure you
follow the coding guidelines provided.
(50 Points)
Use Composition to implement the following:
Use Multiple Source file, Class Definition in header file, class
implementation in .cpp file and application in separate .cpp
file.
Not using these criterias will receive 0 for the points.
Design a TimeCard class that allows a
company to pay a worker for a day’s labor.
The worker uses the time card to punch in at the beginning of the
day and punch out upon quitting.
The company immediately pays the worker based on the hourly rate
and the length of time on the job.
Use composition and incorporate
the Time2 class to keep track of
the
punchInTime (start time)
and punchOutTime (end time) in
the TimeCard class.
Use the following fields as private data for
the Time2:
private int hour;
private int minute;
private int second;
Create all the appropriate method and constructors, with validation
criteria.
Use the following fields as private data for
the TimeCard:
Use the following fields as private data for
the TimeCard:
private string
workerID;
// SS Number
private Time2 punchInTime, punchOutTime; // Time2 objects
private double
payrate;
// hourly pay
private bool
hasPunched;
// set to true after worker punches out
Write a test program that will create
a punchInTime object and
a punchOutTime object.
The class TimeCard should have member
function(s) to calculate the duration (hours worked)
and calculate and print the day’s earnings.
Assume no worker punches in before 8:00 AM and no worker punches
out after 5:00 PM (17.00).
Sample Input/Output:
Worker ID: 123456789
Start Time: 8:00:00 AM
End Time: 3:30:00 PM
Pay Rate: $12.50
Hours worked: 7.50
Per hour, the day's earnings are: $93.75
Worker ID: 997654321
Start Time: 8:00:00 AM
End Time: 4:30:00 PM
Pay Rate: $12.50
Hours worked: 8.50
Per hour, the day's earnings are: $106.25
Table format would be more usable.
Worker
ID
Start Time End Time
Pay Rate Hours Worked
Day's Earning
123456789
8:00:00 AM
3:30:00 PM $12.50
7.50
$ 93.75
997654321
8:00:00 AM 4:30:00 PM
$12.50
8.50
$106.25
In order to get the full point for the assignment, make sure you
follow the coding guidelines provided.