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

Using a structure, and creating three structure variables; write a program that

ID: 3538455 • 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 using the information in the picture.



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.


Total pay should be calculated by multiplying the hours worked by pay rate 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: _ac represents the initials of the programmer. Your function names should


be named by replacing the initials ac with your first and last initials



*MORE INFO ABOUT QUESTION IS IN PICTURE FILE THAT I HAVE POSTED*

Explanation / Answer

#include <iostream>



struct payroll
{
        int emp_id;
        double hrs_wrk;
        double pay_rate;
        double total_pay;
};
payroll admin[10],office[10],field[10];
double get_hrs(int i)
{
    double val;
    std::cout<<"Enter"<<i+1<<" Employee Hours Work:"<<" ";
    std::cin>>val;
    return val;
}
double get_pay_rate(int i)
{
    double val;
    std::cout<<"Enter"<<i+1<<" Employee Pay rate:"<<" ";
    std::cin>>val;
    return val;
}
double cal_pay(int i,double hrs,double rate)
{
    double val;
    val=hrs*rate;
    if(hrs>40)
    {
        val=val+((hrs-40)/5)*(val*0.1);
    }
    return val;
}
void sort(struct payroll* temp)
{
    struct payroll t_swap;
    for(int i=0;i<10;i++)
    {
        for(int j=i+1;j<10;j++)
        {
            if(temp[i].emp_id>temp[j].emp_id)
            {
                //swap...
                t_swap=temp[i];
                temp[i]=temp[j];
                temp[j]=t_swap;
            }
        }
    }
}
void display(struct payroll* temp)
{
    for(int i=0;i<10;i++)
    {

      
        std::cout<<" Employee id:"<<temp[i].emp_id<<" Hrs work:"<<temp[i].hrs_wrk<<" Pay Rate:"<<temp[i].pay_rate<<" Total pay:"<<temp[i].total_pay;
    }
   
   
}

int main()
{
   
    //admin details....
   
    for(int i=0;i<10;i++)
    {
      
        std::cout<<"Enter"<<i+1<<" Employee id:"<<" ";
        std::cin>>admin[i].emp_id;
      
        admin[i].hrs_wrk=get_hrs(i);
        admin[i].pay_rate=get_pay_rate(i);
        admin[i].total_pay=cal_pay(i,admin[i].hrs_wrk,admin[i].pay_rate);
    }
    std::cout<<" ADMIN DETAILS.............. ";
    //displaying admin details
    display(admin);
    //sorting admin...
    sort(admin);
    //display after sort
    std::cout<<" After SORTING values are:";
    display(admin);
   
   
     //office details....
   
    for(int i=0;i<10;i++)
    {
      
        std::cout<<"Enter"<<i+1<<" Employee id:"<<" ";
        std::cin>>office[i].emp_id;
      
        office[i].hrs_wrk=get_hrs(i);
        office[i].pay_rate=get_pay_rate(i);
        office[i].total_pay=cal_pay(i,admin[i].hrs_wrk,admin[i].pay_rate);
    }
    std::cout<<" OFFICE DETAILS.............. ";
    //displaying office details
    display(office);
    //sorting office...
    sort(office);
    //display after sort
    std::cout<<" After SORTING values are:";
    display(office);
   
     //field details....
   
    for(int i=0;i<10;i++)
    {
      
        std::cout<<"Enter"<<i+1<<" Employee id:"<<" ";
        std::cin>>field[i].emp_id;
      
        field[i].hrs_wrk=get_hrs(i);
        field[i].pay_rate=get_pay_rate(i);
        field[i].total_pay=cal_pay(i,field[i].hrs_wrk,field[i].pay_rate);
    }
    std::cout<<" FIELD DETAILS.............. ";
    //displaying field details
    display(field);
    //sorting field...
    sort(field);
    //display after sort
    std::cout<<" After SORTING values are:";
    display(field);
    return 0;
}

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