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 #include main(){ using namespace std; char id[100][12]; char fname[100][14], lname[100][15], status[100][3]; int hw[100]; double gp[100], np[100], hr[100], oth[100], tr[100], ta[100]; int counter = 0; int i; cout << " Professor's PAYROLL INSTITUTE" << endl; //Program title cout <>fname[counter]>>lname[counter]>>status[counter]>>id[counter]>>hw[counter]>>hr[counter]>>oth[counter]) counter=counter+1; for (i=0; i500) tr[i] = .30; else if (gp[i]>200) tr[i] = .20; else tr[i] = .10; for (i=0; i

B) Take advantage of arrays by breaking programs into separate units. Each unit should have a separate loop. (Do not use functions.)

  • Read all data into arrays
  • Compute all the overtimepays
  • Compute all the grosspays
  • Compute all the taxratesCompute all the netpays
  • Display all the arrays

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?

1. #include  2. #include  // file input output stream 3. using namespace std; 4. // function prototypes 5. int readalldata( long int[ ], int[ ], float[ ], const int ); 6. void findovertimehours( int[ ], int[ ], int ); 7. void findovertimepay( int[ ], float[ ], float[ ], int ); 8. void findregularhours( int[ ], int[ ], int ); 9. void findregularpay( int[ ], float[ ], float[ ], int ); 10. void findgrosspay( float[ ], float[ ], float[ ], int ); 11. void findtaxrate( float[ ], float[ ], int ); 12. void findtaxamount( float[ ], float[ ], float[ ], int ); 13. void findnetpay( float[ ], float[ ], float[ ], int ); 14. void printalldata( long int[ ], int[ ], float[ ], float[ ], float[ ], float[ ],float[ ], int ); 15. 16. void main( ){ 17. const int MAXSIZE = 100; // for maximum of 100 employees 18. 19. //declaration of variables 20. int n; 21. long int id[ MAXSIZE ]; 22. int hoursworked[ MAXSIZE ], overtimehours[ MAXSIZE ]; 23. int regularhours[ MAXSIZE ]; 24. float hourlyrate[ MAXSIZE ], regularpay[ MAXSIZE ]; 25. float overtimepay[ MAXSIZE ], grosspay[ MAXSIZE ]; 26. float taxrate[ MAXSIZE ], taxamount[ MAXSIZE ],netpay[ MAXSIZE] ; 27. 28. //functions calls 29. n = readalldata( id, hoursworked, hourlyrate, MAXSIZE ); // get all data 30. findovertimehours( hoursworked, overtimehours, n ); 31. findovertimepay( overtimehours, hourlyrate, overtimepay, n ); 32. findregularhours( hoursworked, regularhours, n ); 33. findregularpay( regularhours, regularpay, hourlyrate, n ); 34. findgrosspay( regularpay, overtimepay, grosspay, n ); 35. findtaxrate( grosspay, taxrate, n ); 36. findtaxamount( grosspay, taxamount, taxrate, n ); 37. findnetpay( grosspay, netpay, taxamount, n ); 38. printalldata( id, hoursworked, hourlyrate, overtimepay, 39. grosspay, taxamount, netpay, n ); 40. }//MAIN
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"< 

Is this for part B or C?

How do I compile both parts B and C?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!