Shahezad Contractor
Captain
Professor Ebrahimi
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[10], lastname[15];
Hint: You may want to use the following I/O manipulators.
#include <iomanip.h>, setw(15), setprecision(2) setiosflags(ios::fixed|ios::showpoint|ios::left)
DR. EBRAHIMI'S PAYROLL INSTITUTE
106 EASY WAYS
PLEASANTVILLE, N.Y. 11068
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 DOE M 223 45 15 5 112..5 675 787.5 275 512.5
B) Convert the program as it is to arrays. Set maxsize of array to 100.
int hw[100],empid[100];
C) Take advantage of arrays by breaking programs into separate units. Each unit should have a separate loop.
· Read all data into arrays.
· Compute all the overtimepays.
· Compute all the grosspays.
· Compute all the taxrates.
· Compute all the netpays.
· Display all the arrays.
D) Include a search by employee id. (An extra-credit)
E) Include a search by employee name. (An extra-credit)
F) Sort the data either by employee id or by employee name.
The nice thing about an array is that as soon as you read the data in it, you
can always go back and look at it using a loop. Therefore loop and array
are "FRIENDS". There is one problem with an array, if you shut down the
computer it is erased. If you create a file and shut down the computer, it
will be saved. Array is faster. RAM=Random Access Memory. Part
C is one loop to read the array, one loop to computer overtimepay, one loop to
compute grosspays, one loop to computer taxrate, one loop to computer netpays.
When you do thte payroll program. It is not one individual programmer.
How many programmers do you need for payroll program. THOUSANDS!
Therefore you must work as a team and take responsibility. Functions will
help you to modularize programs into smaller units so that you can work with a
team. The program you are learning to be done alone, really is not one
persons work. It is hundreds. It is many peoples efforts. If
the information is one loop and one statement in any program you make.
STORY: 1 One my students used this and made a job for himself. Lets
say Sears has 10,000 flyers to mail out. If you sort your zip code a
certain way your postage is not 37 cents. You can get 30 cents per mail if
you sort it correctly.
STORY 2: I was working at NYU and one of the faculty came to me and
doesn't know why in this program this one guy whose starts with Z comes up on
top. Zalowski. I told him to delete his name he deleted it and the
problem went away. He came back to me and said I need Zalowski, he's an
employee. He put him back into the account and it went away. The
problem was that there was a space in front of his name earlier. If you do
not use an array you cannot sort. You have to go back and forth. For
that reason you need an array.
dim employeeid(100) as integer
Shahezad does input
Chris does taxrate
Matty does Taxmount
Ralph does NetPay
Hakeem does GrossPay
Faridah does Output
PLEASE LOOK AT PAGE 139
3 points for Ralph
1 point for Shaadi
1 point for Sunli
1 point for Hakeem
1 point for Christian
1 point for Asma
1 point for Rory