Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective: The purpose of the program is to: 1. Write functions to read in and print an Employee struct 2. Write an additional function that

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Objective: The purpose of the program is to: 1. Write functions to read in and print an Employee struct 2. Write an additional function that passes in an array of Employees and returns the index to a found id. Step 1: Create an Employee.cpp file to go with the existing Employee.h. This involves defining the two functions: o void print Employee (const Employee& c) --print the values of the Employee structure (each record on one line) Employee readEmployee() --ask the user for input and return the Employee structure Remember, you can compile and link the three files with the following commands: g++ -c main.cpp g++ -c Employee.cpp g++ main. Employee.o -o output At this point, your run should look like the following: Employee Name?: Mary Contrary Employee Id?: 1222222 Employee Yearly Salary?: 32003.33 Employee Name?: Sue Morgan Employee Id?: 2444444 Employee Yearly Salary?: 78087.88 Employee Name?: Tom Hinks Employee Id?: 6777777 Employee Yearly Salary?: 89018.38 Employee Name? : Jack Sprat Employee Id?: 8999999 Employee Yearly Salary?: 42018.09 Employee Name?: Scott Burns Employee Id? : 3444444 Employee Yearly Salary?: 22002.89 The Employee info is: Mary Contrary, 1222222, $32003.33 The Employee info is: Sue Morgan, 2444444, $78087.88 The Employee info is: Tom Hinks, 6777777, $89018.38 The Employee info is: Jack Sprat, 8999999, $42018.09 The Employee info is: Scott Burns, 3444444, $22002.89 Step 2: Add this new function prototype to Employee.h: int findEmployee (const Employee array(), int tid, int num); Define the findEmployee function in Employee.cpp the following are the specifications: Arguments: o array: array of Employee(s) tId: the id you are searching for num: the size of the array Returns: 0-1 if the id is not found o an index to the array of Employees where the id was found Add code in main to call the findEmployee function and print out the corresponding name to go with the id. Sample output is: Employee Name? : Mary Contrary Employee Id?: 1222222 Employee Yearly Salary?: 32003.33 Employee Name?: Sue Morgan Employee Id?: 2444444 Employee Yearly Salary?: 78087.88 Employee Name? : Tom Hinks Employee Id?: 6777777 Employee Yearly Salary?: 89018.38 Employee Name?: Jack Sprat Employee Id?: 8999999 Employee Yearly Salary?: 42018.09 Employee Name?: Scott Burns Employee Id?: 3444444 Employee Yearly Salary?: 22002.89 The Employee info is: Mary Contrary, 1222222, $32003.33 The Employee info is: Sue Morgan, 2444444, $78087.88 The Employee info is: Tom Hinks, 6777777, $89018.38 The Employee info is: Jack Sprat, 8999999, $42018.09 The Employee info is: Scott Burns, 3444444, $22002.89 Enter an id to look for: 8999999 Found Employee: Jack Sprat By contrast, if the employee id was not found, you should display a message of: Did not find an Employee with that Id! 6 // Purpose: Implement functions to read in and print an Employee struct 7 // and write an additional function that passes in an array of Employees and 8 // returns the index to a found id 9 // (the functions will be stored in Employee.cpp) 10 11 #include #include using namespace std; 14 #include "Employee.h" 15 16 int main() 17 - { 18 // declare an array of Employees 19 Employee employeeArray [NUM_EMPLOYEES]; 20 // declare a variable for the Employee id to search for in array 21 int employeeId; 22 // declare a variable for index of Employees array where the id was found 23 int employeeIndex; 24 25 cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions