Write a C++ Program , Create a structure called Employee that includes employee ID (string), name of the employee (string), over-time fee (float) and the number of over-time hours during the weekdays (int array).write a function called getEmp( ) which is the data type of Employee that reads the details of Employee and store them in the variable of the Employee structure.Employee getEmp(Employee e);
Write a function called calOTpayment( ) which takes three parameters, over-time fee of the employee, number of over-time hours in weekdays (5 days) array and the size of the array. Find the total payment for the employee and print the total Over-time fee for Weekdays. Call the getEmp( ) and calOTpayment( ) functions in the main function to print the following output as required.
Output
Enter Employee ID: MGK5678
Enter the Name of the Employee : Roy
Enter the over- time Fee : 450
Enter the number of OT Hours for day1:1
#include<iostream>
using namespace std;
struct Employee{
char id[50];
char name_of_empoyee[100];
float overtime_fee;
int overtime_hours[5];
};
Employee getEmp(Employee e) {
cout<<"Enter employee id \t"<<endl;
cin>>e.id;
cout<<"Enter employee name \t"<<endl;
cin>>e.name_of_empoyee;
cout<<"Enter employee over-time fee\t"<<endl;
cin>>e.overtime_fee;
cout<<"Enter employee over-time hours\t"<<endl;
for(int i = 0; i<5; i++){
cout<<"Over-time hours for day\t"<<i+1<<endl;
cin>>e.overtime_hours[i];
}
return e;
}
void calOTpayment(float fee, int days[5], int size ){
float totalPayment = 0.0;
float total_overtime_hours=0.0;
for(int i =0; i<size; i++){
total_overtime_hours += days[i];
}
totalPayment = total_overtime_hours * fee;
cout<<"The total Over-time fee for Weekdays\t"<<totalPayment<<endl;
}
int main(){
struct Employee e, f;
// Calling the getEmp( )
f= getEmp(e);
// Calling the calOTpayment( )
calOTpayment(f.overtime_fee,f.overtime_hours,5);
}
Comments
Leave a comment