Question

Using a structure, and creating three structure variables, write a program that will calculate the total pay for thirty (30)

using c++

output format should look this but use employee id,hours worked and pay rate and the total should be calculated.

Original Data Name Year Tuition David Sylvester Ben 2011 2012 1992 1582.38 728.82 Sorted Data Name Year Tuition Ben David Syl


for example employee id:1234
hours work:29.3
pay rate:16.25

administrative, office and field should be outputted as well too.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>

using namespace std;

typedef struct Emp{
int employees_id;
double hrworked_id;
double payrate_id;
double total_pay_id;
}emp; //For declaring Structure as prescribed

double get_hours(emp e) // For returning hours
{
return e.hrworked_id;
}

double get_payrate(emp e) // For returning payrate
{
return e.payrate_id;
}

void calc_id(emp *e) // calculating Total pay
{
double basePay = e->payrate_id * e->hrworked_id;
if(e->hrworked_id > 40)
{
e->total_pay_id = (e->hrworked_id - 40)*basePay*0.1 + basePay;
}
else
e->total_pay_id = basePay;
}

void sort_id(emp *arr, int size) // Sorting array according to emp_id
{

int i, key, j;
for (i = 1; i < size; i++)
{
key = arr[i].employees_id;
j = i - 1;
while (j >= 0 && arr[j].employees_id > key)
{
arr[j + 1] = arr[j];
j = j - 1;
}
arr[j + 1] = arr[i];
}
}

void prt_id(emp *arr, int size) // Printing array according to the prescription
{
cout<<"\nEmployee_ID\t\t"<<"Hours Worked\t\t"<<"Pay Rate\t\t"<<"Total Pay\n";
int i;
for(i=0;i<size;i++)
{
cout<<"\n"<<arr[i].employees_id<<"\t\t"<<arr[i].hrworked_id<<"\t\t"<<arr[i].payrate_id<<"\t\t"<<arr[i].total_pay_id;
}
}


int main() // Driver Function
{
emp administrative[10],office[10],field[10];
int i;
for(i=0;i<10;i++) // For calculating total pay for each employee
{
calc_id(&administrative[i]);
calc_id(&office[i]);
calc_id(&field[i]);

}

sort_id(administrative,10); // For sorting
sort_id(office,10);
sort_id(field,10);
cout<<"\nAdministrative\n";
prt_id(administrative,10); // For printing
cout<<"\nOffice\n";
prt_id(office,10);
cout<<"\nField\n";
prt_id(field,10);

return 0;
}

// Please leave your rating and ask your doubts in the comment section below.

Add a comment
Know the answer?
Add Answer to:
using c++ output format should look this but use employee id,hours worked and pay rate and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an...

    In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an array of structs to hold the employee information for all employees. If you choose to declare a separate struct for each employee, I will not deduct any points. However, I strongly recommend that you use an array of structs. Be sure to read through Chapter...

  • The rule will be for hours up to 40, calculate pay using the rate entered; for...

    The rule will be for hours up to 40, calculate pay using the rate entered; for any hours above 40, calculate pay as (1.5 * rate). Name your function to compute pay (hours, rate) and use the function to do the computation. You still want to prompt the user for hours and rate OUTSIDE of your function. Name these variables "h" for hours, and "r" for rate: h = float(input('How many hours?: ')) r = float(input('What is your hourly rate?:...

  • An employee has a regular hourly rate equal to $10 and worked 45 hours within a...

    An employee has a regular hourly rate equal to $10 and worked 45 hours within a period of 7 consecutive days. How much overtime pay will the employee earn? What is the TOTAL amount the employer should pay this employee for the 45 work hours?

  • Program is to be written In C++, The output should look like the screen shot. It...

    Program is to be written In C++, The output should look like the screen shot. It should allow the user to continue to ask the user to enter all employee ID's until done and then prompt the user to enter the hours and pay rate for each employee ID. Please help:( Can you please run the program to make sure the output is just like the screenshot please? It needs to have the output that is in the screenshot provided,...

  • (PL/SQL Programming) Consider the table EMPLOYEE with attributes ID, Name, and Hours, and the table PAYINFO...

    (PL/SQL Programming) Consider the table EMPLOYEE with attributes ID, Name, and Hours, and the table PAYINFO with attributes Regular, Overtime, and HourLimit, defined and populated by the following script: DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; CREATE TABLE EMPLOYEE (        ID            CHAR(5),        Name          VARCHAR2(16),        Hours         NUMBER(2),        CONSTRAINT PK_EMPLOYEE               PRIMARY KEY (ID) ); INSERT INTO EMPLOYEE VALUES ('22144', 'Anderson', 30); INSERT INTO EMPLOYEE VALUES ('31902', 'Bruford', 45); INSERT INTO EMPLOYEE VALUES ('42771', 'Wakeman', 20); INSERT INTO EMPLOYEE VALUES...

  • C++ Linked Lists You have been hired by Employees. Inc to write an employee management system....

    C++ Linked Lists You have been hired by Employees. Inc to write an employee management system. The following are your specifications: Write a program that uses the following linked lists: bullet empId: a linked list of seven long integers to hold employee identification numbers. The array should be initialized with the following numbers: 5658845 4520125 7895122 8777541 8451277 1302850 7580489 bullet hours: a linked list of seven integers to hold the number of hours worked by each employee bullet payRate:...

  • // I am going to use if and else stamtents for this employee pay clalulations. //using...

    // I am going to use if and else stamtents for this employee pay clalulations. //using if and else to cal salary //If hours worked is <= 40.0 //Employee salry will = hours*pay rate //else //employess salary will =40*pay rate +(hours worked-40)*1.5* pay rate. #include using namespace std; const double Max_Hours= 40.0; const double MuLTIPLER = 1.5; char salary; char payrate; char hours_worked; char Max_hours; char get_total_pay; int main() { double Hours=0; double Payrate = 0; cout <<"Please enter employee...

  • Write a program to prompt the user for hours and rate per hour using input to...

    Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called computepay() and use the function to do the computation. The function should return a value. Use 45 hours and a rate of 10.50 per...

  • C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their...

    C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...

  • I NEED ALL QUESTIONS OR ELSE THUMBS DOWN! C++ Implement a structure Employee. An employee has...

    I NEED ALL QUESTIONS OR ELSE THUMBS DOWN! C++ Implement a structure Employee. An employee has a name (a char *) and a salary (a double). Write a default constructor, a constructor with two parameters (name and salary), and methods char* getName() double getSalary() to return the name and salary. Write a small global function TestEmployee() to test your structure. Creating a new employee. Please type the name: Larry Bird Please specify the salary: 200000 New employee has been created....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT