Question
Using a structure, and creating three structure variables; write a C++ program that will calculate the total pay for thirty (30) employees. (Ten for each
Using a structure, and creating three structure variables; write a C++ program that will calculate the total pay for thirty (30) employees. (Ten for each structured variable.) Sort the list of employees by the employee ID in ascending order and display their respective information. Description - DataType -
Members Employee IDs - of INT -employees_jf
Hours Worked - of DOUBLE - hrworked_jf
Pay Rate - of DOUBLE - payrate_jf
Total Pay - of Double - total_pay
------------------------------------------------
Array size administrative - structure - variable -10
office - structure - variable -------------10
field - structure -variable ---------------10
Excluding the main function, your program should have five additional functions that will get the hours worked, and payrate, calculate the total pay, sort the data and display your output. Base payshould be calculated by multiplying the regular hours worked by pay rate.If a person has worked over forty (40)hours, total pay is calculated by an adding10% ofbase pay for every five (5) hours over forty (40)to base pay.(ie a person working 50 hours with a total pay of $100 would have ((hours-40)/5)*(base pay*.1)+ base pay. But this time create a file (datafile) that has your full name, Course name and Date on the first three lines. Write the program to open the output file in append mode and write your output to this file. When the execution of your C++ is complete, your output file should contain your name, course name and date followed by the 10 employee records including their total pay, THAT IS MY ASSIGNMENT SO COULD SOMEONE GET A LOOK AT MY PROGRAM AND FIX MY ERRORS? HERE IS:
//include the needed header files
#include
#include
#include
using namespace std;
//STRUCTURE DEFINITION
struct EMPINFO
{
int myEMPID;
double WrkdHrs;
double bsePayRt;
double talPay;
};
EMPINFO adminEMPS[10],officeEMPS[10],fieldEMPS[10];
//get HOURS WORKED
void getHrWorked(struct EMPINFO* temp,int id)
{
double myWrkHrs;
int id;
for(int aa=0;aa<10;aa++)
{
cout<<"EMTER ID";
cin>>id;
cout<<"Enter WORKED HOURS:";
cin>>myWrkHrs;
temp[aa].WrkdHrs=myWrkHrs;
temp[aa].myEMPID=id;
}
}
//GET BASE PAY RATE
void getBasePayRat(struct EMPINFO* temp)
{
double myRt;
for(int aa=0;aa<10;aa++)
{
cout<<"Enter Payrate";
cin>>myRt;
temp[aa].bsePayRt=myRt;
}
}
//Calculate total-pay
void calculatePay(struct EMPINFO* temp)
{
for(int aa=0;aa<10;aa++)
{
temp[aa].talPay=(temp[aa].bsePayRt*temp[aa].WrkdHrs);
if(temp[aa].WrkdHrs>40)
temp[aa].talPay+=((temp[aa].WrkdHrs-40)/5)*(temp[aa].talPay*0.1);
}
}
void sortEMPINFO(struct EMPINFO* temp)
{
struct EMPINFO swapEMPS;
for(int aa=0;aa<10;aa++)
{
for(int bb=aa+1;bb<10;bb++)
{
if(temp[aa].myEMPID > temp[bb].myEMPID)
{
swapEMPS=temp[aa];
temp[aa]=temp[bb];
temp[bb]=swapEMPS;
}
}
}
}
//display EMPSINFO
void displayEMPSINFO(struct EMPINFO* temp)
{
for(int aa=0;aa<10;aa++)
{
cout<
}
}
//main
int main()
{
fstream fID;
fID.open("outfile.txt",ios::app);
//read total WORKED HOURS for all employees
cout<<"READING ADMIN EMPLOYEES WORKED HOURS: "<
getHrWorked(adminEMPS);
cout<<"READING OFFICE EMPLOYEES WORKED HOURS: "<
getHrWorked(officeEMPS);
cout<<"READING FIELD EMPLOYEES WORKED HOURS: "<
getHrWorked(fieldEMPS);
//READING BASE RATE
cout<<"READING ADMIN EMPLOYEES BASE RATE: "<
getBasePayRat(adminEMPS);
cout<<"READING OFFICE EMPLOYEES BASE RATE: "<
getBasePayRat(officeEMPS);
cout<<"READING FIELD EMPLOYEES BASE RATE: "<
getBasePayRat(fieldEMPS);
//CALCULATING TOTAL PAY
cout<<" CALCULATING TOTAL PAY for ADMIN EMPLOYEES : "<
calculatePay(adminEMPS);
cout<<" CALCULATING TOTAL PAY for OFFICE EMPLOYEES: "<
calculatePay(officeEMPS);
cout<<" CALCULATING TOTAL PAY for EMPLOYEES: "<
calculatePay(fieldEMPS);
//SORT
sortEMPINFO(adminEMPS);
sortEMPINFO(officeEMPS);
sortEMPINFO(fieldEMPS);
//display
displayEMPSINFO(adminEMPS);
displayEMPSINFO(officeEMPS);
displayEMPSINFO(fieldEMPS);
if(fID.is_open())
{
fID<<"Name:XXXX"<
fID<<"Course:Computer Science"<
fID<<"Date:12/02/2016"<
//writing to file
for(int aa=0;aa<10;aa++)
{
fID<
}
for(int aa=0;aa<10;aa++)
{
fID<
}
for(int aa=0;aa<10;aa++)
{
fID<
}
fID.close();
}
system("pause");
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started