Using a structure, and creating three structure variables; write a program that
ID: 3766974 • Letter: U
Question
Using a structure, and creating three structure variables; write a 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_jd Hours Worked of DOUBLE hrworked_jd Pay Rate of DOUBLE payrate_jd Total Pay of Double total_pay Structure name payroll 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 pay should 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 adding 10% of base 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. Note: _jd represents the initials of the programmer. Your function names should be named by replacing the initials jd with your first and last initials Read Input File Calculate Pay Sort Data Output Results Name of function get_jd calc_jd sort_jd prt_jd Properties of function Called from main Called from main Called from main Called from main Definition of Function Should pass hours worked and pay rate Should pass hours worked and pay rate and calculate total pay Sort data by student ID using the bubble or selection sort. Should pass employee id, hours worked, pay rate and total pay and print data. This is a C++ program plus I need to use a input data file in this program.
Write a C++ program that will read 10 records into an array from a data file. Each record should contain an employee ID, hours worked and pay rate. You should calculate a total pay and then write the record to an output file. The Record written should consist of Employee ID, hours worked, pay rate and total pay. Description DataType Variables Employee IDs of INT employees_jd Hours Worked of DOUBLE hrworked_jd Pay Rate of DOUBLE payrate_jd Total Pay of Double total_pay Excluding the main function, your program should have three additional functions that will get the employee id, hours worked, and payrate; another to calculate the total pay; and another to write your output to the output file. Total pay should be calculated by multiplying the hours worked by payrate plus 10% of total pay for every five (5) hours over forty (40). (ie a person working 50 hours with a total pay of $100 would have ((50-40)/5)*(100*.1) added to total pay. Note: _jd represents the initials of the programmer. Your function names should be named by replacing the initials jd with your first and last initials Read Input File Calculate Pay Output Results Name of function get_jd calc_jd prt_jd Properties of function Called from main Called from main Called from main Definition of Function Should pass employee id, hours worked and payrate Should pass hours worked and payrate and calculate total pay Should pass employee id, hours worked, payrate and total pay and write data. This program is the same as the above program but with an ouput data file and the first part is an input data file.
Explanation / Answer
#include <iostream.h>
#define MAXARRAY 2
struct Record{
int idnum;
char employeename[20];
double pay_rate;
double hrs_worked;
double emp_pay;
double gross_pay;
};
int main (){
int i;
struct Record payment[MAXARRAY];
cout<<" This program will calculate the amount of pay for employees entered.";
cout<<"Program will calculate pay for up to 6 employees. "<<;
for (i = 0; i < MAXARRAY; i++){
cout<<"Enter employee ID Number: "<<;
cin<<"%d", &payment[i].idnum<<endl;
cout<<"Enter employee Last Name: "<<;
cin<<"%s", &payment[i].lname<<endl;
cout<<"Enter employee Pay Rate: $"<<;
cin<<"%f", &payment[i].pay_rate<<;
cout<<"Enter employee Hours Worked: "<<;
cin<<"%f", &payment[i].hrs_worked<<;
}
for (i = 0; i < MAXARRAY; i++){
payment[i].emp_pay = payment[i].pay_rate * payment[i].hrs_worked;
payment[i].gross_pay += payment[i].emp_pay;
cout<<" The Pay for employee #%d is %f", payment[i].idnum, payment[i].emp_pay<<;
}
return 0;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.