ing to be working with partially filled arrays that are parallel with each other. That means that the row index in multiple arrays identifies different pieces of data for the same person. This is a simple payroll system that just calculates

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

C++ PLEASE HELP MUST MATCH OUTPUT IN PICS

In this lab, you're going to be working with partially filled arrays that are parallel with each other. That means that the row index in multiple arrays identifies different pieces of data for the same person. This is a simple payroll system that just calculates gross pay given a set of employees, hours worked for the week and hourly rate.

Parallel Arrays

First, you have to define several arrays in your main program

  1. employee names for each employee
  2. hourly pay rate for each employee
  3. total hours worked for each employee
  4. gross pay for each employee

You can use a global SIZE of 50 to initialize these arrays

Second, you will need a two dimension (2-D) array to record the hours worked each day for an employee. The number of rows for the 2-D array should be the same as the arrays above since each row corresponds to an employee. The number of columns represents days of the week (7 last I looked)

Functions Needed

In this lab, you must read in the employee names first because this identifies how many elements will be in each array. Then you will have to read in the hourly pay rate for each employee

You must implement two functions: getEmployeeNames and getHourlyPay

/* TODO: Create a function called 
getEmployeeNames
 Arguments :
  Name array(first and last name)
  Maximum size
  Return the number of names filled (Have the user enter "quit" to end input early).
*/

/* TODO: Create a function called
getHourlyPay
 Arguments :
  NameArray(filled in Step 1)
  HourlyPayArray(starts empty)
  NumberOfNamesFilled(from Step1)
*/

Two additional functions: getHighestPay and getLowestPay should use the gross pay array and the number of employees to figure out the highest and lowest pay respectively. HINT: return the index of the highest/lowest gross pay so that when you print the answer in main, you can access the gross pay and the name

Nested Loops for Daily Hours

Once you have the names and hourly pay rate, you have to ask the user to enter the hours worked for each employee. Expect to read in hours for 7 days, the user will put 0 for days off. This will require a loop that traverses the rows (each employee) and another loop that traverses the hours worked for the days

Another set of nested loops are needed to sum up the daily hours into total hours worked and use that to calculate the gross pay for the week.

Once you have this, you now have everything you need to create the table which contains only the employee names, the total hours worked and the gross pay (no need to traverse the 2-D array again!)

Program Output

Employee Name, Total Hours and Gross Pay

Use the output information below to space your output in the three arrays that will be printed: employee names, total hours and gross pay.

    cout << setw(20) << "Employee Name" << setw(12) << "Total Hours" << setw(10) << "Gross Pay" << endl;

(include <iomanip> in your code to use setw)

Again, you are working with parallel arrays, so use the same index to access elements in each array for an employee.

Employee Name, Total Hours and Gross Pay

Finally, use the functions that you wrote to calculate the highest and lowest gross pay and print this info according to the test case output. These functions only need the gross pay array and the number of elements in it. Each function should return the index of the target value in the gross pay array

STARTER CODE

// TODO:Add function prototypes for all the declared functions

// TODO:Declare two functions to compute the highestPay and lowestPay
// HINT:Each should return the index of the correct value in the grossPay array

/* TODO:Create a function called
getEmployeeNames
Arguments :
Name array(first and last name)
Maximum size
Return the number of names filled.
*/

/* TODO:Create a function called
getHourlyPay
Arguments :
NameArray(filled in Step 1)
HourlyPayArray(starts empty)
NumberOfNamesFilled(from Step1)
*/

int main()
{
//TODO:Declare an array of strings for the employeeNames able to hold a maximum of SIZE employees

//TODO:Declare arrays of double hourlyPay and grossPay, each able to hold a maximum of SIZE employees

//TODO:Declare a 2-D array of doubles for the hours. It should hold a maximum of SIZE employees, each having 7 days

//TODO:Read in the employee names and return the numberOfEmployees

//TODO:Call your function to read in the hourly pay for each of the employees

//TODO:Read in the daily hours for each employee. There will be 7 entries per week

//NOTE:This prints the headers with a set width for each field. Follow this format for the entries
cout << setw(20) << "Employee Name" << setw(12) << " Hours" << setw(10) << "Gross Pay" << endl;

//TODO:For each employee, print: name, total hours and gross pay

//TODO:Call the function that finds the highest gross pay and print the corresponding employee name and gross pay
//HINT:consider finding the Index of the value rather than returning the actual highest gross pay
//TODO:Call the function to find the lowest gross pay and print the corresponding employee name and gross pay

return 0;
}

THE CORRECT OUTPUT OF THE TEST CASE
Enter an employee name: Enter an employee name: Enter an employee nane: Enter an employee name: Enter an employee name: Enter an employee name: Enter an employee name: Enter an employee name: Enter an employee nane: Enter
Adam Ant
7.40
364.08
Bart simpson
n
23.80
276.0
George washington
Boaty McBoatface
23.20
322.48
19.10
878.60
Midge Haisel
Jed Bartlett
16.98
545.87
26.20
272.48
Rachel Carson
Charlie Young
15.Ge
455.52
31.90
1113.31
10
Marvin Gardens
18.90
669.06
11
Jane Bolin
17.00
387.60
12
Garry Trudeau
14.30
278.85
13
Barbara MCClintock 43.5e 2018.40
14 Highest Pay: $2018.40 Barbara Mcclintock
15 LOwest Pay: $272.48 Jed Bartlett
Part 2 (going across line 1)
THE CORRECT OUTPUT OF THE EST CAS
Enter an employee name: Enter an employee name: Enter an employee nane: Enter an employee name: Enter Adam Ant's hourly pay rete: Enter Bert Simpson's hourly pay rate: Enter George Mashington's hourly pay rate: Enter Boaty McB
HE CORRECT OUTPUT OF THE TEST CASE
Enter Jane Bolin's hourly pay rate: Enter Garry Trudeau's hourly pay rate: Enter Barbara KClintock's hourly pay rate: Enter Adan Ant's hours for 7 days (e if day off): Enter Bart sipson's heurs for 7 days (e if day off): Ente
THE COECT OUTPUT OF THE TEST CASE
Boatface's hourly pay rate: Enter Hidge Haisel's hourly pay rate: Enter Jed Bartlett's hourly pay rate: Enter kachel carson"s hourly pay rate: Enter Charlie Young's hourly pay rate: Enter arvin Gardens's hourly pay rate: Ent
THE CORRECT OUTPUT OF THE TEST CASE
Enter George Mashington's hours for 7 days (e if day off): Enter Boaty McBoatface's hours for 7 days (e if day off): Enter Hidge Maisel's hours for 7 days (e if day off): Enter Jed Bartlett's hours for 7 days (e if day off): En
THE CORRECT OUTPUT OF THE TEST CASE
nter Rachel Carson's hours for 7 days (e if day ofH): Enter Charlie Young's hours for 7 days (e if day off): Enter Marvin Gardens's hours for 7 days (e 1f day off): Enter Jane Bolin's hours for 7 days (e if day off): Enter Gart
Enter Garry Trudeau's hours for 7 days (e if day off): Enter Barbara Mcclintock's hours for 7 days (e if day off):
Employee Nane Total Hours Gross Pay
Transcribed Image Text:THE CORRECT OUTPUT OF THE TEST CASE Enter an employee name: Enter an employee name: Enter an employee nane: Enter an employee name: Enter an employee name: Enter an employee name: Enter an employee name: Enter an employee name: Enter an employee nane: Enter Adam Ant 7.40 364.08 Bart simpson n 23.80 276.0 George washington Boaty McBoatface 23.20 322.48 19.10 878.60 Midge Haisel Jed Bartlett 16.98 545.87 26.20 272.48 Rachel Carson Charlie Young 15.Ge 455.52 31.90 1113.31 10 Marvin Gardens 18.90 669.06 11 Jane Bolin 17.00 387.60 12 Garry Trudeau 14.30 278.85 13 Barbara MCClintock 43.5e 2018.40 14 Highest Pay: $2018.40 Barbara Mcclintock 15 LOwest Pay: $272.48 Jed Bartlett Part 2 (going across line 1) THE CORRECT OUTPUT OF THE EST CAS Enter an employee name: Enter an employee name: Enter an employee nane: Enter an employee name: Enter Adam Ant's hourly pay rete: Enter Bert Simpson's hourly pay rate: Enter George Mashington's hourly pay rate: Enter Boaty McB HE CORRECT OUTPUT OF THE TEST CASE Enter Jane Bolin's hourly pay rate: Enter Garry Trudeau's hourly pay rate: Enter Barbara KClintock's hourly pay rate: Enter Adan Ant's hours for 7 days (e if day off): Enter Bart sipson's heurs for 7 days (e if day off): Ente THE COECT OUTPUT OF THE TEST CASE Boatface's hourly pay rate: Enter Hidge Haisel's hourly pay rate: Enter Jed Bartlett's hourly pay rate: Enter kachel carson"s hourly pay rate: Enter Charlie Young's hourly pay rate: Enter arvin Gardens's hourly pay rate: Ent THE CORRECT OUTPUT OF THE TEST CASE Enter George Mashington's hours for 7 days (e if day off): Enter Boaty McBoatface's hours for 7 days (e if day off): Enter Hidge Maisel's hours for 7 days (e if day off): Enter Jed Bartlett's hours for 7 days (e if day off): En THE CORRECT OUTPUT OF THE TEST CASE nter Rachel Carson's hours for 7 days (e if day ofH): Enter Charlie Young's hours for 7 days (e if day off): Enter Marvin Gardens's hours for 7 days (e 1f day off): Enter Jane Bolin's hours for 7 days (e if day off): Enter Gart Enter Garry Trudeau's hours for 7 days (e if day off): Enter Barbara Mcclintock's hours for 7 days (e if day off): Employee Nane Total Hours Gross Pay
INPUT OF THE TEST CASE
1 Adam Ant
2 Bart Simpson
3 George Washington
4 Boaty McBoatface
5 Midge Maisel
6 Jed Bartlett
7 Rachel Carson
8 Charlie Young
9 Marvin Gardens
10 Jane Bolin
11 Garry Trudeau
12 Barbara McClintock
13 quit
14 49.20
15 11.60
16 13.90
INPUT OF THE TEST CASE
17 46.00
18 32.30
19
10.40
20 29.20
21
34.90
22
35.40
23
22.80
24
19.50
25
46.40
26
3.9
e.2
8.3
27
4.3
5.2
3.9
3.4
28 2.5
1.6
6.7
6.8
5.6
29
2.7
e.5
4.1
5.7
6.1
30
1.9
0.3
7.6
2.8
4.3
31
5.5
7.1
6.
7.6
32
1.3
5.8
4.5
e.7
3.3
32 1.3
5.8
4.5
0.7
3.3
33 6
7.6
1.7
5.9
2.5
7.2
34 e
5.5
2.1
0.2
7.1
4
35 5.4
4.2
3.8
e
1.1
2.5
36 e
5.3
8.8
0.3
7.9
37 6.5
6.5
7.9
7.1
7.5
2.3
5.7
Transcribed Image Text:INPUT OF THE TEST CASE 1 Adam Ant 2 Bart Simpson 3 George Washington 4 Boaty McBoatface 5 Midge Maisel 6 Jed Bartlett 7 Rachel Carson 8 Charlie Young 9 Marvin Gardens 10 Jane Bolin 11 Garry Trudeau 12 Barbara McClintock 13 quit 14 49.20 15 11.60 16 13.90 INPUT OF THE TEST CASE 17 46.00 18 32.30 19 10.40 20 29.20 21 34.90 22 35.40 23 22.80 24 19.50 25 46.40 26 3.9 e.2 8.3 27 4.3 5.2 3.9 3.4 28 2.5 1.6 6.7 6.8 5.6 29 2.7 e.5 4.1 5.7 6.1 30 1.9 0.3 7.6 2.8 4.3 31 5.5 7.1 6. 7.6 32 1.3 5.8 4.5 e.7 3.3 32 1.3 5.8 4.5 0.7 3.3 33 6 7.6 1.7 5.9 2.5 7.2 34 e 5.5 2.1 0.2 7.1 4 35 5.4 4.2 3.8 e 1.1 2.5 36 e 5.3 8.8 0.3 7.9 37 6.5 6.5 7.9 7.1 7.5 2.3 5.7
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
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