or this assignment, you will write a program that reads employee work data from a text file, and then calculates payroll information based on this file. The text file will contain one line of text for each employee. Each line consists of the following data (delimited by spaces or tabs): 1) employee’s id 2) employee’s hourly wage rate 3) hours worked Monday 4) hours worked Tuesday 5) hours worked Wednesday 6) hours worked Thursday 7) hours worked Friday ex) txt file attached Your program should first prompt the user to get the location of the input file. Then it will read the data from the file, put it in appropriate arrays (as described below), and output to the screen the following information: (1) the employee ID, total number of hours worked, regular pay, overtime hours, overtime pay, and total paid to each employee (2) the total hours worked by all employees throughout the week; (3) the total amount paid out to all employees for the week; (4) the employee who received the highest pay for the week, as well as the amount that employee was paid; (5) the employees who worked less than the average number of hours; and (6) a list of the employees in reverse order. You must use standard input stream (easily done using Scanner) and standard output stream for your user IO in this assignment. When the program begins, you will see a prompt for the file path and the user should enter the value using the standard input stream (in Netbeans this is the output screen). After the user enters the input path of the file, the results for the data file shown above should look like this: attached. Note: overtime pay is time-and-a-half. So, the per hour payment for time above 40 hours should be calculated accordingly. This is shown with emp4, who worked six hours of overtime at 50% over their normal $13.75 per hour. You can see that, in addition to each employee’s details, also displayed are the totals, highest paid employee, employees working less than average hours, and employees in reverse order. Your program must be flexible enough to handle a variety of input files. There may be as many as 100 employees in the file. But in all cases, each line of the text file will be structured as described above. To make this work, you will need to create three arrays. One array will contain the employee names. A second array will contain the hourly wages earned by each employee. The third contains the total number of hours worked by each employee. These are parallel arrays. This means that the same index in each array pertains to the same entity. These arrays must be large enough to handle an unknown number of employees. As stated above, there can be as many as 100 employees in the file. But there may also be less than 100. Therefore, although these arrays must be large enough for the maximum amount, many of the elements of the arrays may be empty. So, you should also have a variable to keep track of how many employees are actually read from the file. This total employees variable will also be used to keep track of the next available element in the names and wages arrays, and can be used to index into these arrays. For example, the total employees variable starts at 0, which means that you will index into element 0 of these arrays. For each employee that you read from the file, you can increment the total employees variable. Thus, after you have processed the first employee, the total employees variable will be 1, so you will index into element #1 of the arrays. After you’ve processed the second employee from the file, the total employees variable will be 2, so you will index into element #2 of the arrays. Thus, the total employees variable serves two purposes: keeping a running count of the employees and indexing into the arrays. You will also need other variables for keeping track of totals, inputting data from the file, finding the maximum value in the array, etc.   Program Logic: The logic of the program works something like this: 1) Prompt the user for the name of the file, and read response. 2) Open the input file specified by the user 3) Loop continuously: a. Read the name and wage b. Read the five days hours work and add them together c. Place these values into the appropriate arrays at the next available position d. add one to the count of total employees. You can use the total employee count to index into the arrays. 4) At this point you have accumulated all the data into the arrays. Now it is simply a matter of displaying the results, determining the max-paid employee, displaying the employees working less than average hours, and printing the names in reverse order. Each of these will be done in a loop. Keep in mind that when you calculate the pay for an employee, you need to account for overtime. Any hours over 40 that an employee works within the week should be paid at 1.5 times their normal pay rate. For the above data, emp4 shows an example of this.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

For this assignment, you will write a program that reads employee work data from a text file, and then calculates payroll information based on this file. The text file will contain one line of text for each
employee. Each line consists of the following data (delimited by spaces or tabs):
1) employee’s id
2) employee’s hourly wage rate
3) hours worked Monday
4) hours worked Tuesday
5) hours worked Wednesday
6) hours worked Thursday
7) hours worked Friday

ex) txt file attached



Your program should first prompt the user to get the location of the input file. Then it will read the data from the file, put it in appropriate arrays (as described below), and output to the screen the following information: (1) the employee ID, total number of hours worked, regular pay, overtime hours, overtime pay, and total paid to each employee (2) the total hours worked by all employees throughout the week; (3) the total amount paid out to all employees for the week; (4) the employee who received the highest pay for the week, as well as the amount that employee was paid; (5) the employees who worked less than the
average number of hours; and (6) a list of the employees in reverse order. You must use standard input stream (easily done using Scanner) and standard output stream for your user IO in this assignment.


When the program begins, you will see a prompt for the file path and the user should enter the value using the standard input stream (in Netbeans this is the output screen). After the user enters the input path of the file, the results for the data file shown above should look like this: attached.

Note: overtime pay is time-and-a-half. So, the per hour payment for time above 40 hours should be calculated accordingly. This is shown with emp4, who worked six hours of overtime at 50% over their normal $13.75 per hour. You can see that, in addition to each employee’s details, also displayed are the totals, highest paid employee, employees working less than average hours, and employees in reverse order. Your program must be flexible enough to handle a variety of input files. There may be as many as 100
employees in the file. But in all cases, each line of the text file will be structured as described above.

To make this work, you will need to create three arrays.
One array will contain the employee names. A second array will contain the hourly wages earned by each employee. The third contains the total number of hours worked by each employee. These are parallel arrays. This means that the same index in each array pertains to the same entity.

These arrays must be large enough to handle an unknown number of employees. As stated above, there can be as many as 100 employees in the file. But there may also be less than 100. Therefore, although these arrays must be large enough for the maximum amount, many of the elements of the arrays may be empty. So, you should also have a variable to keep track of how many employees are actually read from the file. This total employees variable will also be used to keep track of the next available element in the names and wages arrays, and can be used to index into these arrays. For example, the total employees variable starts at 0, which means that you will index into element 0 of these arrays. For each employee that you read from the file, you can increment the total employees variable. Thus, after you have processed the first employee, the total employees variable will be 1, so you will index into element #1 of the arrays. After you’ve processed the second employee from the file, the total employees variable will be 2, so you will index into element #2 of the arrays. Thus, the total employees variable serves two purposes: keeping a running count of the employees and indexing into the arrays. You will also need other variables for keeping track of totals, inputting data from the file, finding the maximum value in the array, etc.

 

Program Logic:


The logic of the program works something like this:
1) Prompt the user for the name of the file, and read response.
2) Open the input file specified by the user
3) Loop continuously:
a. Read the name and wage
b. Read the five days hours work and add them together
c. Place these values into the appropriate arrays at the next available position
d. add one to the count of total employees. You can use the total employee count to index
into the arrays.
4) At this point you have accumulated all the data into the arrays. Now it is simply a matter of displaying the results, determining the max-paid employee, displaying the employees working less than average hours, and printing the names in reverse order. Each of these will be done in a loop. Keep in mind that when you calculate the pay for an employee, you need to account for overtime. Any hours over 40 that an employee works within the week should be paid at 1.5 times their normal pay rate. For the above data, emp4 shows an example of this.

 

empwages.txt - Notepad
File Edit Format View Help
emp1
emp2
emp3
emp4
10
2
7.5
8
6
12.50
4
7
5
3.3
2.2
20
1
1
1
1.5
13.75
8
8
10
10
10
Ln 3, Col 20
100%
Windows (CRLF)
UTF-8
Transcribed Image Text:empwages.txt - Notepad File Edit Format View Help emp1 emp2 emp3 emp4 10 2 7.5 8 6 12.50 4 7 5 3.3 2.2 20 1 1 1 1.5 13.75 8 8 10 10 10 Ln 3, Col 20 100% Windows (CRLF) UTF-8
run:
Enter full path of input file:
empwages..txt
Επp ID
Hours
Reg Pay OT Hrs OT Pay Tot Pay
0.0 $0.00
0.0 $0.00
empl
27.5
$275.00
$275.00
emp2
21.5
$268.75
$268.75
emp3
5.5
$110.00
0.0 $0.00
$110.00
emp4
46.0
$632.50
6.0 $41.25 $673.75
Total hours worked:
100.5
Total payroll:
$1,327.50
The highest paid employee was emp4 who earned $632.50
Average hours worked
25.125
The following employees worked less than the average:
emp2
emp3
Employees printed in reverse order:
emp4
emp3
emp2
empl
BUILD SUCCESSFUL (total time: 7 seconds)
Transcribed Image Text:run: Enter full path of input file: empwages..txt Επp ID Hours Reg Pay OT Hrs OT Pay Tot Pay 0.0 $0.00 0.0 $0.00 empl 27.5 $275.00 $275.00 emp2 21.5 $268.75 $268.75 emp3 5.5 $110.00 0.0 $0.00 $110.00 emp4 46.0 $632.50 6.0 $41.25 $673.75 Total hours worked: 100.5 Total payroll: $1,327.50 The highest paid employee was emp4 who earned $632.50 Average hours worked 25.125 The following employees worked less than the average: emp2 emp3 Employees printed in reverse order: emp4 emp3 emp2 empl BUILD SUCCESSFUL (total time: 7 seconds)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education