#include #include #include #include #include using namespace std; void PrintReportHeadings(); void PrintColumnHeadings(); void PrintEmployeeLine(string, float, float, float,float, float); void PrintaLine(int, char); void SkipLines (int); void indent (int); void process_payroll(); float computePay(float hours, float rate, float &overtimePay ,float &x); ofstream outReport ("c:payroll.doc" ); string name; float payrate, hours, othours, otwages, totalwage; int main() { PrintReportHeadings(); process_payroll(); return 0; } void PrintColumnHeadings(){ outReport << setiosflags(ios::right) << setw (10) << "Name" << setw(10) << "payrate" << setw(10) <<"Hours" << setw(10) << "OThours" << setw(10) << "OTwages" << setw(10) <<"Total Wage" << endl; } void PrintReportHeadings() { PrintaLine (65, ':'); indent(19); SkipLines(1); PrintaLine (65, '.'); PrintColumnHeadings(); PrintaLine (65, '.'); } void PrintaLine(int n, char c){ for (int i=1; i<=n; i++) outReport << c; outReport << endl; } void SkipLines (int n){ for (int i=1; i<=n; i++) outReport << endl; } void indent (int n){ for (int i=1; i<=n; i++) outReport << ' '; } void PrintEmployeeLine (string name, float payrate, float hours, float othours, float otwages, float totalwage) { outReport << setiosflags (ios::fixed) << setprecision(2) << setw (11) << setiosflags (ios::left) << name << setiosflags(ios::right) << setw(10) << payrate << setw(10) << hours << setw (10) << othours << setw (10)<< otwages << setw (10)<< totalwage << endl; } void process_payroll() { char more_data = 'y'; while( more_data == 'y' || more_data == 'Y') { otwages=0; float regular_pay=0; cout << "Enter the Name ,payrate and hours of employee\n"; cin >> name; cin >> payrate; cin >> hours; regular_pay=computePay(hours,payrate,otwages,othours); totalwage=regular_pay+otwages; PrintEmployeeLine(name,payrate,hours,othours,otwages,totalwage); cout << "\n\nMore Employees (Y/N) : "; fflush(stdin); cin >> more_data; } } float computePay(float hours, float rate, float &overtimePay ,float &x) { float regularPay = 0; x = 0; overtimePay = 0; if (hours > 40) { regularPay = 40 * rate; (x) = hours - 40; if (x > 10) { overtimePay = (((x) - 10) * 2 * rate) + (10*1.5*rate); } else { overtimePay = (x) * 1.5 * rate; } } else { { regularPay = hours * rate; } } return regularPay; }