Still having problems with this program. This is what output should look like: E
ID: 3647566 • Letter: S
Question
Still having problems with this program. This is what output should look like:Enter employee's name: John Doe
Enter hours worked: 35
Enter hourly rate: -10
Hourly rate must be positive
Please re-enter hourly rate: 10
Another employee? (Y/N): y
Enter employee's name: Sue Johnson
Enter hours worked: 50.5
Enter hourly rate: 15.50
Another employee? (Y/N): y
Enter employee's name: Tom Jones
Enter hours worked: 40
Enter hourly rate: 12.25
Another employee? (Y/N): y
Enter employee's name:
Name field may not be blank
Please re-enter name: Elmo Jones
Enter hours worked: 10
Enter hourly rate: 10
Another employee? (Y/N): n
PAYROLL REPORT
Employee Name Hours Rate Pay
John Doe 35.00 $ 10.00 $ 350.00
Sue Johnson 50.50 $ 15.50 $ 864.13
Tom Jones 40.00 $ 12.25 $ 490.00
Elmo Jones 10.00 $ 10.00 $ 100.00
Total Payroll $1804.13
Press any key to continue
This is what I have but not working.....
#include<iostream>
#include<string>
using namespace std;
#include"employee.h"
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;
getData(company, size);
printPayroll(company, size);
}
int getData(Employee list[], int size)
{
for (int index = 0; index < size; index++)
{
string tempname;
char choice;
float temphours, temprate;
int count;
do{
cout << "Enter employee's name: ";
getline(cin, tempname);
cout << "Enter hours worked: ";
cin >> temphours;
cout << "Enter hourly rate: ";
cin >> temprate;
list[index].setData(tempname,temphours,temprate);
cout<<"Another employee? (Y/N): ";
cin>>choice;
cin.ignore(1);
cout<<endl;
}while(toupper(choice) != 'N');
return size;
}
}
void printPayroll(Employee list[], int elems)
{
for (int index=0; index < elems; index++)
{
cout << "Empoyee Name"<<index+1<<endl;
cout << "Name: " << list[index].getName() << endl;
cout << "Hours: " << list[index].getHours() << endl;
cout << "Rate: " << list[index].getRate() << endl;
cout << "Pay: " << list[index].getPay() << endl;
}
}
Explanation / Answer
post ur employee.h file
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.