Question: How do I properly do this? A) Display company title and a header that labels the output in a tabular form. Input the first name
How do I properly do this?
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)
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.
In above A-C parts, the part A is the transition, and the part B will convert to array by adding indexes. The part B supposed to take advantage of array by having every action of loop and independent. How to convert A to B? I have written following code so far for part A, which needs to include marital status-based tax computation also.
using namespace std;
int main(){
char id[100][14];
char fname[100][14], lname[100][15], status[100][3], ssn[100][10];
int hw[100],n;
double gp[100], np[100], hr[100], oth[100], tr[100], ta[100];
int counter = 0;
int i;
cout<<" "<
cout<
cout<<"FIRST NAME LAST NAME MARITAL STAT SSN HW HR"<
while(cin>>fname[counter]>>lname[counter]>>status[counter]>>ssn[counter]>>hw[counter]>>hr[counter])
counter=counter+1;
for (i=0; i
{
gp[i] = hw[i] * hr[i];
}
for (i=0; i
{
if (gp[i]>500) tr[i] = .30;
else if (gp[i]>200) tr[i] = .20;
else tr[i] = .10;
}
for (i=0; i
ta[i]= gp[i] * tr[i];}
for (i=0; i
np[i] = gp[i] - ta[i];
}
cout
<
<
<
<
<
<
<
for (i=0; i
cout
<
<
<
<
<
<
<
}
ofstream outdata;
outdata.open("pay.txt");
if( !outdata )
{
cerr << "Error: file could not be opened" << endl;
exit(1);
}
for
(i=0; i
{
outdata
<
<
<
<
<
<
}
outdata.close();
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
