Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help finishing this program here what I still need: Make a function to inpu

ID: 3647545 • Letter: N

Question

Need help finishing this program here what I still need:


Make a function to input the data. You will pass the array to the function. The prototype should be:
int getData(Employee[], int);
It is passed the array and the max size of the array. It prompts for all the data and stores it in the array. It returns the actual number of employees that are input. [WHY IS THIS NECESSARY TO KNOW?] Write and test this function first! Make sure you are not allowed to exceed the size of the array.
Now write a function to display the payroll report. Note that this function also calculates and prints the total amount of the payroll. The prototype should be:
void printPayroll(Employee[], int);


Here's what I got:

void showEmps(Employee[], int);
int getData(Employee[], int);
void printPayroll(Employee[], int);
void main()
{
const int size = 10; //will make it easy to modify
Employee company[size]; //declare an array of structures
string tempname;
float temphours, temprate;


}
int getData(Employee list[], int elems)
{
for (int index = 0; index < elems; index++)
{
string tempname;
float temphours, temprate;

cout << "Enter name: ";
cin >> tempname; //or getline(cin, tempname);
cout << "Enter hours: ";
cin >> temphours;
cout << "Enter rate: ";
cin >> temprate;

list[index].setData(tempname,temphours,temprate);
return index;
}

}
void printPayroll(Employee[], int)
{

}
cpp.file
#include"employee.h"

Employee::Employee()
{
hours = 0;
rate = 0;
pay = 0;
}
void Employee:: setData(string nam, float hou , float ra)
{
eName = nam;
hours = hou;
rate = ra;

}
float Employee::getPay()
{
pay = hours*rate;
return pay;
}
header file:

class Employee
{
private:
string eName;
float hours, rate, pay;

public:
Employee();
void setData(string, float, float);
string getName() { return eName; }
float getHours() { return hours; }
float getRate() { return rate; }
float getPay();

};

Explanation / Answer

void showEmps(Employee[], int); int getData(Employee[], int); void printPayroll(Employee[], int); void main() { const int size = 10; //will make it easy to modify Employee company[size]; //declare an array of structures string tempname; float temphours, temprate; } int getData(Employee list[], int elems) { for (int index = 0; index tempname; //or getline(cin, tempname); cout > temphours; cout > temprate; list[index].setData(tempname,temphours,temprate); return index; } } void printPayroll(Employee list[], int elems) { for (int index = 0; index
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote