logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

This program will read from a file and calculate the gross pay of each of the employees reads the EMPLOYEE ID#. After the employee ID, there are 7 numbers, each representing the number of hour.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

This program will read from a file and calculate the gross pay of each of the employees. The program reads the EMPLOYEE ID#. After the employee ID, there are 7 numbers, each representing the number of hours the employee worked for each day of the week. For some employees, specific pay rates are given. (See input file details on next page). The program will display the gross pay of each of the employees.

Declare the following global constants:

  • REGULAR_HOURS with the value 40.00 – This represents the number of regular hours for a worker for a week. (It will be used to determine overtime. If hours worked during a week is greater than the regular hours, then they have worked overtime hours)
  • MIN_WAGE with the value 13.50 – the current minimum wage for NYC

Write a program that defines following functions (only the function name is given. You have to determine the return type and parameter list based on the description. Define and test each function with minimal statements in main()

 

before you begin writing another function. **W

 

rite a comment above each function, describing what it does **

 

  • show_money() – takes a number and prints the number with a dollar sign, the dollar amount followed by a . and two digits after the decimal. (This will be called any time you need to display a value as )
  • worked_overtime() – takes a number (not necessarily a whole number) which represents the number of hours worked in a week. The function will compare this parameter with the global constant REGULAR_HOURS: if the hours worked in week is greater than REGULAR HOURS, then return true. Otherwise return false. (hint: setup is similar to is_even() function we wrote in class)
  • calc_overtime_hours() – takes the number of hours worked in a week and calculates the number of overtime hours. Returns the number of overtime
  • calc_overtime_rate() – calculates how much the worker is paid per hour of This will be 1.5 times their regular pay_rate.
  • calculate_pay() – this function calculates gross pay. It takes the number of hours worked for a week and the regular pay rate (how much the worker earns per hour). The default argument for the pay rate is minimum wage (this will be used if the pay rate is omitted in the function call). Make sure the constant MIN_WAGE is defined before the prototype for calculate_pay().

 

This is going to be a function that calls another function: In the body of this function, there is a call worked_overtime() which returns true or false. Call this function to determine if the worker has worked overtime.

The setup of the rest of this algorithm may vary. You might want to declare some other local variables in this function to help with calculations:

In general, the gross pay is (hours worked (not including overtime) multiplied by pay_rate) plus (overtime hours multiplied by overtime rate). Use the functions calc_overtime_hours() and calc_overtime_rate().

 

Or you can break it down to two situations:

If the worker has no overtime, the gross pay is hours worked multiplied by pay_rate. Otherwise, there is overtime and program will multiply the REGULAR_HOURS by the pay rate. Add this to the product of calculate_overtime_hours() multiplied by calc_overtime_rate().

The function returns the gross pay.

  • calculate_pay() – this is an o verloaded function. The parameters will be hours worked, pay rate, and overtime rate. This function allows for the function to receive a value for overtime rate instead of having the function calculate overtime rate as 1.5x the regular

Return the gross pay.

You should use your main() function to test calls to each function before finalizing main(). Also test one employee before putting the code in a loop.

 

 

About the input file and the 3 types of employees:

week1.txt

900001

10.5 0 7 6 7.5 7 0

900005

7 7 7 0 0 7 6.5

900003

0 8.75 8.5 8 8 7.5 0

900004

0 0 7.5 7.5 7 7 7.5

800001

0 8.75 8.5 8.5 8 7.5 0

800002

10 9 8 7.5 6.5 0 0

500001

10.5 9.5 0 6.25 6.5 0 10.5 50.15

500002

9 9.5 9 6.5 8.5 0 0 55.76

500003

10 10 0 6.5 6.5 6.5 10.5 50.29

400001

7.5 9 8 0 6.5 7 10.5 40.13

400002

0 9 8 6.5 6.5 0 10.5 45.76

300001

10.5 9 8 6.5 6.5 0 10.5 39.88

300002

10 9 10 9 0 0 0 30.01

200001

0 10.5 11 11 0 0 0 26.53

200002

0 0 12 12 0 0 12 25.78

100000

12 12 0 0 0 0 12 122.22 200.00

100002

13 14 6 0 0 0 12 122.22 200.00

 

Each line of the input file represents an employee’s work hours for the week, some have more info about their rates. The first integer is their employee ID#. The next 7 numbers are their hours -- one for every day of the pay period (a week).

All employee IDs have 6 digits, first digit is not zero.

Employee IDs that start with a 8 or 9 earn minimum wage, their overtime rate is 1.5x their regular rate. In the file, these lines only have the ID # and the 7 hours.

Employee IDs that start with 2, 3, 4, 5, 6 or 7 have a specified pay rate. In the file, these lines have ID #, 7 hours, and the pay rate.

Employee IDs that start with a 1 have specified pay rate and a specified overtime rate. In the file, these lines have ID #, 7 hours, the pay rate, and the overtime rate.

 

Sample output:

Employee

900001

earned

$513.00 for this pay period.

Employee

900005

earned

$465.75 for this pay period.

Employee

900003

earned

$555.19 for this pay period.

Employee

900004

earned

$492.75 for this pay period.

Employee

800001

earned

$565.31 for this pay period.

Employee

800002

earned

$560.25 for this pay period.

Employee

500001

earned

$2250.48 for this pay period.

Employee

500002

earned

$2439.50 for this pay period.

Employee

500003

earned

$2765.95 for this pay period.

Employee

400001

earned

$2116.86 for this pay period.

Employee

400002

earned

$1864.72 for this pay period.

Employee

300001

earned

$2253.22 for this pay period.

Employee

300002

earned

$1335.45 for this pay period.

Employee

200001

earned

$862.23 for this pay period.

Employee

200002

earned

$928.08 for this pay period.

Employee

100000

earned

$4399.92 for this pay period.

Employee

100002

earned

$5888.80 for this pay period.

 

Finish your functions and test them first. Hints for main() method on next page.

 

Checklist for your program (including pseudocode hints for main() method and reading from file)

 

Comment including your name and a description of the program.

Preprocessor directives using namespace std;

Declare and initialize global constants Declare function prototypes

 

Pseudocode/ algorithm for main() {

Declare your variables for the filestream, the variables for data that will be read by the file, an accumulator for the total hours.

Setup your filestream with the file name Test that the file opens without error.

If there is an error,

print a error message.

Otherwise:

While there is an employee id number to read from the file:

Print beginning of sentence: “Employee _(ID# here)_ made ”

Reset your accumulator (total hours) to 0 before summing for each employee Loop to read the next 7 numbers (the hours for each day)

Accumulate the sum of the hours

If the employee id starts with 8 or 9 (since all ID #s have 6 digits, one approach is id# >= 800000) Call calculate_pay() passing only the total hours, allowing for the rate to be the default

Otherwise, if the employee id starts with 2,3,4,5,6 or 7 (id# > 200000 and id# < 800000) Read the next number (pay rate) from the file

Call the calculate_pay() function by passing the total hours and the pay rate.

Otherwise, the employee id starts with a 1

Read the next two numbers: pay rate and over time rate from the file

Call the calculate_pay() function by passing the total hours, pay rate, overtime rate Print the gross pay using your show_money() function.

Print the end of the sentence “ for this pay period.” End of while loop

Close input file stream. return 0;

}

 

/*Function definitions go here. Don’t forget to write a comment for each function. Typically, describe the parameter, the return value (if it has a return value), and a short description about what the function does*/

Sample style for function comments. You can adopt any style you like but remember that code and comments are provided for clarity.

//***************************************************************

// show_money()                                                   *

// parameter(s): double money - represents a monetary value       *

// This function prints money formatted as USD: a '$' precedes    *

// the amount and two digits after the decimal place are shown    *

//***************************************************************

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

509 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

888 Answers

Hire Me
expert
Husnain SaeedComputer science

655 Answers

Hire Me
expert
Atharva PatilComputer science

751 Answers

Hire Me