Question: In c++ program: Write functions to read in and print an Employee struct and Write an additional function that passes in an array of Employees

In c++ program: Write functions to read in and print an Employee struct and Write an additional function that passes in an array of Employees and returns the index to a found id.

Note: I tried this on my own and manage to finish step1. I'm current stuck in Step 2. Please post your version of how to solve this program.

In c++ program: Write functions to read in and print an Employee

struct and Write an additional function that passes in an array of

Here is the code for existing Employee.h

#include using namespace std;

const unsigned int NUM_EMPL=5;

struct Employee { string name; int id; double salary; };

void printEmployee(const Employee& c); Employee readEmployee(); //----Add findEmployee prototype for Step 2----

Here is the code for existing main.cpp

#include #include using namespace std; #include "Employee.h"

int main() { Employee employees[NUM_EMPL]; int tempId; int index;

cout

for (int i=0; i

//----Add code below for Step2---- //prompt the user for an id //call the findEmployee function

//if found, display the name of the employee that goes with the id }

Create an Employee.cpp file to go with the existing Employee.h. This involves defining the two functions o void printEmployee (const Employee& c) -print the values of the Employee structure (each record on one line) o 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 o g++-c main.cpp o g++ C Employee.cpp o g++ main.o 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?: 7887 .88 Employee Name? Tom Hinks 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 he Employee info is: Mary Contrary, 1222222, $32003.33 he Employee info is: Sue Morgan, 2444444, $7887.88 he Employee info is: Jack Sprat, 8999999, $42018.09 he Employee info is: Scott Burns, 3444444, $22002.89

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Sure Lets proceed with step 2 Youll want to define the findEmployee function and incorporate it into ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!