Payroll System

CASE STUDY – PAYROLL SYSTEM PHASE 5: ARRAY
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)



DR. EBRAHIMI'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

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 had created the program and it is working, however when I compute the program the format of it gets all messed up. Is there anything that I am missing in this program?

by the way, I am not understanding what question b is asking ither? need assistance.

Here is my code by the way so far.



#include <iostream>

#include <iomanip>

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 <<endl;

cout<<"Enter Employee id, First and Last Names, SS#, Hours Worked,and Hourly Rate. Press ctrl- z and Enter to end"<<endl;

while(cin>>fname[counter]>>lname[counter]>>status[counter]>>id[counter]>>hw[counter]>>hr[counter]>>oth[counter])



counter=counter+1;

for (i=0; i<counter; i++){

gp[i] = hw[i] * hr[i];}

for (i=0; i<counter; i++);

if (gp[i]>500) tr[i] = .30;

else if (gp[i]>200) tr[i] = .20;

else tr[i] = .10;



for (i=0; i<counter; i++){

ta[i]= gp[i] * tr[i];}

for (i=0; i<counter; i++){

np[i] = gp[i] - ta[i];

}



cout<<setw(14)<<"Employee ID"<<setw(16)<<"First Name"<<setw(17)

<<"Last Name"<<setw(4)<<"HW"<<setw(5)<<"HR"<<setw(6)

<<"GROSS"<<setw(6)<<"TAX"<<setw(9)<<"Net Pay"<<endl<<endl;

for (i=0; i<counter; i++){

cout<<setw(14)<<id[i]<<setw(16)<<fname[i]<<setw(17)<<lname[i]<<setw(4)

<<hw[i]<<setw(5)<<hr[i]<<setw(6)<<gp[i]<<setw(6)<<ta[i]<<setw(9)<<np[i]<<endl;









}





return(0);


}//MAIN

What is the problem?
Does it compile? If not, are there any errors?
What are they?
If it does compile, does the program not run as expected?
Tell us what happens and what is supposed to happen,
Line 5: main must be type int

Line 9: using namespace std; is out of place. Harmless, but by convention it should go after line 3.

Line 41: Your for loop does nothing. The ; terminates the loop.

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Thank for your response. I have figured this one out and It is working
Topic archived. No new replies allowed.