Question
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.
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.
Here is my code and input file. I keep getting the error: [Error] expected unqualified-id before numeric constant
What am I doing wrong??? Please help !
"payroll.in"
1225 S Saverio Smith 45 20 7995 H Michelle Smith 50 25 8716 m Santino Smith 35 30 1512 s Nicholas Smith 30 12 1513 M Julianna Smith 42 24
#include
using namespace std;
int readalldata(long int[],char[],char[],char[],int[],double[],const int); //FUCNTION PROTOTYPES void computeotp(int[],int[],double[],int); void computegp(double[],int[],double[],double[],double[],int); void computetaxrate(double[],double[],int); void computemtaxrate(char[],double[],double[],int); void computenetpay(double[],double[],double[],double[],double[],int); void displayarrays(long int[],char[],char[],char[],int[],double[],int[],double[],double[],double[],double[],double[],int);
main(){ const int MAXSIZE = 100; //FOR MAX OF 100 EMPLOYEES int n; long int employeeid[MAXSIZE]; char marital[MAXSIZE]; char firstname[MAXSIZE], lastname[MAXSIZE]; double hourlyrate[MAXSIZE], grosspay[MAXSIZE], netpay[MAXSIZE], taxrate[MAXSIZE], mtaxrate[MAXSIZE], taxamount[MAXSIZE], regpay[MAXSIZE], otpay[MAXSIZE]; int hoursworked[MAXSIZE], othours[MAXSIZE]; //DECLARATION OF ALL VARIABLES
//FUCNTION CALLS n = readalldata(employeeid,marital,firstname,lastname,hoursworked,hourlyrate,MAXSIZE); //GETS ALL THE DATA computeotp(hoursworked,othours,otpay,n); computegp(grosspay,hoursworked,hourlyrate,otpay,regpay,n); computetaxrate(grosspay,taxrate,n); computemtaxrate(marital,mtaxrate,taxrate,n); computenetpay(taxamount,grosspay,taxrate,mtaxrate,netpay,n); displayarrays(employeeid,marital,firstname,lastname,hoursworked,hourlyrate,othours,otpay,regpay,grosspay,taxamount,netpay,n); }//MAIN
//FUCNTION DEFINITIONS int readalldata(long int employeeid[],char marital[],char firstname[],char lastname[],int hoursworked[],double hourlyrate[],int n){ ifstream fin("payroll.in"); n = 0; while(fin>>employeeid[n]>>marital[n]>>firstname[n]>>lastname[n]>>hoursworked[n]>>hourlyrate[n]) n++; fin.close(); return n; }//READALLDATA
void computeotp(int hoursworked[],int othours[],double hourlyrate[],double otpay[],int n){ for(int i = 0;i < n;i++){ if (hoursworked[i] > 40) othours[i] = (hoursworked[i] - 40); //COMPUTE ALL OVERTIME HOURS/PAY otpay[i] = othours[i] * (hourlyrate[i] * 1.5); if (hoursworked[i] < 40) otpay[i] = 0; else othours[i] = 0; }//FOR }//COMPUTEOTP void computegp(double grosspay[],int hoursworked[],double hourlyrate[],double otpay[],double regpay[],int n){ for(int i = 0;i < n;i++){ grosspay[i] =(hoursworked[i] * hourlyrate[i]) + otpay[i]; //COMPUTE ALL THE GROSSPAYS regpay[i] = (grosspay[i] - otpay[i]); //COMPUTE REGULAR PAY }//FOR }//COMPUTEGP
void computetaxrate(double grosspay[],double taxrate[],int n){ //COMPUTE ALL THE TAXRATES for(int i = 0;i < n;i++){ if(grosspay[i] > 1000) taxrate[i] = 0.30; else if((grosspay[i] > 800) && (grosspay[i] <= 1000)) taxrate[i] = 0.20; else if((grosspay[i] > 500) && (grosspay[i] < 800)) taxrate[i] = 0.10; else if((grosspay[i] >= 0) && (grosspay[i] <= 500)) taxrate[i] = 0.0; }//FOR }//COMPUTETAXRATE
void computemtaxrate(char marital[],double mtaxrate[],double taxrate[],int n){ //COMPUTE MARITAL TAXRATES for(int i = 0;i < n;i++){ if(marital[i] == 'S' || marital[i] == 's') mtaxrate[i] += 0.05; else if(marital[i] == 'H' || marital[i] == 'h') mtaxrate[i] -= 0.05; else taxrate[i]; }//FOR }//COMPUTEMTAXRATE
void computenetpay(double taxamount[],double grosspay[],double taxrate[],double mtaxrate[],double netpay[],int n){ //COMPUTE ALL THE NETPAYS for(int i = 0;i < n;i++){ taxamount[i] = (grosspay[i] * (taxrate[i] + mtaxrate[i])); netpay[i] = grosspay[i] - taxamount[i]; }//FOR }//COMPUTENETPAY
void displayarrays(long int employeeid[],char marital[],char firstname[],char lastname[],int hoursworked[],double hourlyrate[],int othours[],double otpay[],double regpay[], double grosspay[],double taxamount[],double netpay[],int n){ //DISPLAY ALL THE ARRAYS cout<<" DR. EBRAHIMI'S PAYROLL INSTITUTE"<
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started