Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the following code, I need to: 1. Instead of using separate variables to store employee information (employee1, employee2, etc.), modify you program from the

Using the following code, I need to:

  1. 1. Instead of using separate variables to store employee information (employee1, employee2, etc.), modify you program from the previous task to declare an array of structs to hold the information of up to 100 employees. Name the array empList

  1. 2. Use function getEmployeeInfo() to read data for at least 3 employees into array empList. You can prompt the user to tell you how many employees they want to enter. Be sure to save the number of employee entered into a variable.

  1. 3. Use function displayEmplyeeInfo() to display the employee information in empList. Use the same output format at in the previous task.

#include

#include

using namespace std;

struct address

{

string street, city, state;

int zipCode;

};

struct EmployeeRec

{

string name;

string empId;

double payRate;

double hours;

address add;

};

EmployeeRec empList[100];

address readAddress()

{

address d;

cout << "enter the street";

cin >> d.street;

cin.ignore(100, ' ');

cout << "enter the city";

cin >> d.city;

cout << "enter the state";

cin >> d.state;

cout << "enter the zip code";

cin >> d.zipCode;

return d;

}

EmployeeRec getEmployeeInfo()

{

int numEmployee;

cout << "How many employees do you want to enter";

cin >> numEmployee;

for (int i = 0; i < numEmployee-1; ++i)

{

EmployeeRec Info;

cout << "enter employee name";

cin >> Info.name;

cin.ignore(100, ' ');

cout << "enter employee ID";

getline(cin, Info.empId);

cout << "enter pay rate";

cin >> Info.payRate;

cout << "enter hours worked";

cin >> Info.hours;

Info.add = readAddress();

return Info;

}

}

void displayAddress(address d)

{

cout << d.street << " " << d.city << " ," << d.state << ", " << d.zipCode;

}

void displayEmployeeInfo(EmployeeRec x)

{

cout << x.name << ", " << x.empId << ", ";

cout << x.payRate << ", " << x.hours << ". " << x.payRate*x.hours << ", ";

displayAddress(x.add);

}

using namespace std;

int main()

{

EmployeeRec x;

x = getEmployeeInfo();

cout << endl;

displayEmployeeInfo(x);

cout << endl;

system("pause");

return 0;

}

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

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

ISBN: 1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

Evaluate the radical expression by hand. (363/4)2

Answered: 1 week ago