Question: Payroll System- I really need help. I am using Dev-C++. CASE STUDY- PAYROLL SYSTEM PHASE 5- ARRAY, How do I properly do this on my
Payroll System- I really need help. I am using Dev-C++.
CASE STUDY- PAYROLL SYSTEM PHASE 5- ARRAY, How do I properly do this on my Dev-C++?
The purpose of this phase is to expand the payroll system to display all employee information in a tabular form by including arrays.
A) Display company title and a header that labels the output in a tabular form. Input the first name and last name of an employee.
char firstname[100][10], lastname[100][15]; or you may use #include using namespace std; string firstname[100], lastname[100]; int hw[100],empid[100];
Hint: You may want to use the following I/O manipulators.
#include , setw(15), setprecision(2) setiosflags(ios::fixed|ios::showpoint|ios::left)
Professor's PAYROLL INSTITUTE
| FIRST NAME | LAST NAME | STAT | SSN | HW | HR | OTH | OTP | REGP | GROSS | TAX | NET |
| ======== | ======== | ==== | ==== | === | === | ==== | ===== | ===== | ===== | ===== | ===== |
| John | Smith | M | 113 | 50 | 20 | 10 | 300 | 800 | 1100 | 385 | 715 |
| Jane | Dow | M | 223 | 45 | 15 | 5 | 112.5 | 675 | 787.5 | 275 | 512.5 |
I did this top part, here is my compilation:
#include B) Take advantage of arrays by breaking programs into separate units. Each unit should have a separate loop. (Do not use functions.) C) Include separate functions to read in the data, compute the gross pay, tax rate, net pay, and overtime pay for all employees, and display. I properly completed part A. How do I compile both parts B and C? Also, this compilation, would this be for part B or C? Is this for part B or C? How do I compile both parts B and C?
1. #include
41. int readalldata( long int id[ ], int hoursworked[ ], float hourlyrate[ ], int n ){ 42. ifstream fin( "payroll.in" ); 43. n = 0; 44. 45. while( fin >> id[ n ] >> hoursworked[ n ] >> hourlyrate[ n ] ) n++; 46. 47. fin.close( ); 48. return n; 49. }//READALLDATA 50. 51. void findovertimehours( int hoursworked[ ], int overtimehours[ ], int n ){ 52. for( int i = 0 ; i < n ; i++){ 53. if( hoursworked[ i ] > 40 ) overtimehours[ i ] = hoursworked[ i ] - 40; 54. else overtimehours[ i ] = 0; 55. }//FOR 56. }//FINDOVERTIMEHOURS 57. 58. void findovertimepay( int overtimehours[ ], float hourlyrate[ ], 59. float overtimepay[ ], int n ){ 60. for( int i = 0 ; i < n ; i++){ 61. overtimepay[ i ] = overtimehours[ i ] * hourlyrate[ i ] * 1.5; 62. }//FOR 63. }//FINDOVERTIMEPAY 64. 65. void findregularhours( int hoursworked[ ], int regularhours[ ], int n ){ 66. for( int i = 0 ; i < n ; i++){ 67. if( hoursworked[ i ] > 40 ) regularhours[ i ] = 40; 68. else regularhours[ i ] = hoursworked[ i ]; 69. }//FOR 70. }//FINDREGULARHOURS 71. 72. void findregularpay( int regularhours[ ], float regularpay[ ], 73. float hourlyrate[ ], int n ){ 74. for( int i = 0 ; i < n ; i++ ){ 75. regularpay[ i ] = regularhours[ i ] * hourlyrate[ i ]; 76. }//FOR 77. }//FINDREGULARPAY 78. void findgrosspay( float regularpay[ ], float overtimepay[ ], 79. float grosspay[ ],int n ){ 80. for( int i = 0 ; i < n ; i++){ 81. grosspay[ i ] = regularpay[ i ] + overtimepay[ i ]; 82. }//FOR 83. }//FINDGROSSPAY 84. 85. void findtaxrate( float grosspay[ ], float taxrate[ ], int n ){ 86. for( int i = 0 ; i < n ; i++){ 87. if( grosspay[ i ] > 4000.00 ) taxrate[ i ] = 0.40; 88. else if(grosspay[ i ] > 3000.00 ) taxrate[ i ] = 0.30; 89. else if(grosspay[ i ] > 1000.00 ) taxrate[ i ] = 0.20; 90. else taxrate[ i ] = 0.10; 91. }//FOR 92. }//FINDTAXRATE 93. 94. void findtaxamount( float grosspay[ ], float taxamount[ ], 95. float taxrate[ ], int n ){ 96. for( int i = 0 ; i < n ; i++){ 97. taxamount[ i ] = grosspay[ i ] * taxrate[ i ]; 98. }//FOR 99. }//FINDTAXAMOUNT 100. 101. void findnetpay( float grosspay[ ], float netpay[ ], float taxamount[ ], int n){ 102. for( int i = 0 ; i < n ; i++){ 103. netpay[ i ] = grosspay[ i ] - taxamount[ i ]; 104. }//FOR 105. }//FINDNETPAY 106. 107. void printalldata( long int id[ ], int hoursworked[ ], float hourlyrate[ ], 108. float overtimepay[ ], float grosspay[ ], float taxamount[ ], 109. float netpay[ ], int n ){ 110. cout << "EMP ID" << "\t" << "HOURS" << "\t" << "RATE " << "\t " 111. << "OVERPAY " << "\t" << "GROSSPAY" << "\t" << "TAX "<< "\t" 112. << " NETPAY " << endl; 113. for( int i = 0 ; i < n; i++){ 114. cout << " " << id[ i ] << "\t " << hoursworked[ i ] << "\t"<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
