//File :Long_program_assignment1.cpp //Author :Andre Long //Due :July 7, 2005 //Description:The purpose of this program is to demostrate a C program using Sequence Selection and Iteration // and to output the results to a report file using functions (modular design) #include #include #include #include #include #define TAXRATE .15; using namespace std; string getFullName(); //Input functions float getPay(); float getTotalHours(float* TotalHours); float processRegularPay(float* TotalHours, float* payrate); //Processing functions float processOvertimePay(float* TotalHours, float* payrate); float processGrossPay(float* TotalHours, float* payrate); float processTaxAmount(float* TotalHours, float* payrate); float processNetPay(float* TotalHours, float* payrate); void display(int numberOfEmployees, string* fullnames, float* payrate, float* TotalHours, float* grossPay, float* taxAmount, float* netPay); //Output functions void reportFile(fstream &, int numberOfEmployees, string* fullnames, float* payrate, float* TotalHours, float* grossPay, float* taxAmount, float* netPay); int main(void) { char userAnswer; int numberOfEmployees; string* fullnames; float* payrate; float* TotalHours; float* regularPay; float* overtimePay; float* grossPay; float* taxAmount; float* netPay; fstream reportOut("Payroll Report.doc", ios::out | ios::app); if(!reportOut) { cout<<"Error with report"<<"\n"; exit(0); } cout<<"How many employees are there in this company? "; cin>>numberOfEmployees; fullnames = new string[numberOfEmployees]; payrate = new float[numberOfEmployees]; TotalHours = new float[numberOfEmployees]; regularPay = new float[numberOfEmployees]; overtimePay = new float[numberOfEmployees]; grossPay = new float[numberOfEmployees]; taxAmount = new float[numberOfEmployees]; netPay = new float[numberOfEmployees]; do { for(int i=0; i>userAnswer; } while (userAnswer =='Y' || userAnswer =='y' ); reportOut.close(); return 0; } string getFullName() { string first; string last; string punctuation = ", "; string FullName; cout<<"\n"; cout<<"Enter employee's first name "; cin>>first; cout<<"\n"; cout<<"Enter employee's last name "; cin>>last; FullName = last + punctuation + first; return FullName; } float getPay() { float moneyValue; cout<<"Enter the pay rate for this employee "; cin>>moneyValue; return moneyValue; } float getTotalHours(float* TotalHours) { float allHours; cout<<"Enter the total number of hours worked for this employee "; cin>>allHours; return allHours; } float processRegularPay(float* TotalHours, float* payrate) { float regular_pay; if(*TotalHours<=40) { regular_pay = *TotalHours *( *payrate ); return regular_pay; } else { regular_pay = 40 *( *payrate ); return regular_pay; } } float processOvertimePay(float* TotalHours, float* payrate) { float overtime_pay; overtime_pay = ( *TotalHours - 40 ) * (1.5 * (*payrate) ); return overtime_pay; } float processGrossPay(float* TotalHours, float* payrate) { float gross_pay; if(*TotalHours > 40) { gross_pay = processRegularPay(TotalHours, payrate) + processOvertimePay(TotalHours, payrate); } else { gross_pay = processRegularPay(TotalHours, payrate) + 0; } return gross_pay; } float processTaxAmount(float* TotalHours, float* payrate) { float tax_amount; tax_amount = processGrossPay(TotalHours, payrate) * TAXRATE; return tax_amount; } float processNetPay(float* TotalHours, float* payrate) { float net_pay; net_pay = (processGrossPay(TotalHours, payrate) - processTaxAmount(TotalHours, payrate) ); return net_pay; } void display(int numberOfEmployees, string* fullnames, float* payrate, float* TotalHours, float* grossPay, float* taxAmount, float* netPay ) { cout<<"\n"; cout<<"Employee"<