Code questions

We are supposed to "expand" a payroll program to utilize arrays. looking at the examples in our textbook, it appears that we actually have to reprogram (drastically change) the payroll program every two chapters. It is an online class with little professor-student interaction and the textbook is sometimes lacking.

The instructions are:
Display company title and a header that labels the output in a tabular form. Input the first name and last name of an employee.

I am assuming that he wants us to input simply the first name and last name to get data in tabular form.

Right now, I am experimenting with this file while I try to figure out what he wants, but I get an error: line 16; expected primary-expression before ')' token

I lost week because of the holiday but I am trying to catch up! Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  #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 First and Last Names, SS#, Hours Worked,and Hourly Rate. Press ctrl- z & 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


Thanks in advance! I will probably have more questions though I keep reading tutorials and threads here.
closed account (SECMoG1T)
Yeah on line 16

 
while(cin>>fname[counter]>>lname[counter]>>status[counter]>>id[counter]>>hw[counter]>>hr[counter]>>oth[counter]>>)  ///** what is the last >>  intended to do, check it out*// you also missed a loop brace '{' 


Yeah that's it, however if you are allowed to use classes they would make your work easier
Thanks, I missed that; was very tired. This assignment is stressing me out. Classes start in the next module I believe. The above code is an example from the textbook with some modifications. I am assuming that the expanded program has to be a modified version of my last assignment which contained this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <fstream>
using namespace std;

int main(){
    int hw, id; //hours worked and employee id
    float hr, gp, ta, np, TR, ; //hourly rate, gross pay, tax amount, net pay, tax rate,
    char msh;
    string str;
    ifstream fin("employee.in"); //input file

	cout << "________________________" << endl; //Program title
	cout << "   DrEbrahimi.com Inc" << endl;
	cout << "Employee Payroll Program" << endl;
	cout << "________________________" << endl;
	cout <<endl;

	while(fin>>id>>hw>>hr>>msh){

    if(hw <= 40)	{
		gp = hw * hr; //regular time	}
	else
	{		gp = (40 * hr) + (hw - 40) * (hr * 1.5); //calculating overtime	}
	if( gp > 1000 ) TR = 0.30;
	else if( gp > 800) TR = 0.20;
    else if( gp > 500) TR = 0.10;
    else TR = 0.0;
    switch(msh)
   
 {    case 'S': TR+=0.05;
    break;
    case 'M': TR+=0.10;
    break;
    case 'H': TR-=0.05;
    break;
    }
    np = gp * (1.0-TR);
    ta = gp * TR;
   
 cout << "Employee ID Number Is: " << id << endl;
	cout << "Total Clocked Hours: " << hw << endl;
	cout << "Hourly Pay Rate: $ " << hr << endl;
	    cout << "Employee Gross Pay This Week: $" << gp << endl;
	cout << "Current Tax Rate: "  << TR << "%" << endl;
	cout << "Tax Deduction Amount: $" << ta << endl;
    cout << "Employee Net Pay: $" << np << endl<<endl;
    }//while
    cout << "Press the enter key to close the program.";
   
 cin.get();
    return(0);


With the instruction for this assignment, I think he only wants us to input the first name and last name of an employee which will out put the following values:

First Name, Last Name, Status, SSN, HW, HR, OTH, OTP, REGP, GROSS, TAX, NET all in tabular form. I am lost as how to get started.
Last edited on
Topic archived. No new replies allowed.