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:
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:
#include <iostream>
#include <fstream>
usingnamespace 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;
elseif( gp > 800) TR = 0.20;
elseif( 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.