Question: Can anyone help me to solve this problem? I want to Initialize the first 3 Employee array locations for each Employee Type...but It seems like
Can anyone help me to solve this problem? I want to Initialize the first 3 Employee array locations for each Employee Type...but It seems like over something?
Also plz help me to detect errors in my code.




My code?
#include
#include
#include
#include
using namespace std;
class employee
{
protected:
string employeeid;
float hours;
float pay;
float taxrate;
float overtime;
string empstatus;
public:
void setID(string id)
{
employeeid=id;
}
void sethours(float hrs)
{
hours=hrs;
}
void setpay(float payRate)
{
pay=payRate;
}
void settaxrate(float tax)
{
taxrate=tax;
}
void setstatus(string status)
{
empstatus=status;
}
string getid() {return employeeid;}
float gethours() {return hours;}
float getpay() {return pay;}
string getstatus() {return empstatus;}
employee()
{
employeeid = "N/A";
hours = 0;
pay = 0;
taxrate = 0;
overtime = 0;
empstatus = "N/A";
}
virtual void terminate(){}
virtual void calculatepay(){}
virtual void setovertime(){}
};
class Hourly : public employee
{
public:
void calculatepay()
{
cout
cout
cout
cout
cout
cout
cout
cout
cout
}
void Overtime()
{
if (hours
overtime = 0;
else
overtime = hours - 40;
hours = 40;
}
void terminate()
{
pay=0;
hours=0;
taxrate=0;
overtime=0;
empstatus="Hourly - Terminated";
}
};
class Salaried : public employee
{
public:
void calculatepay()
{
cout
cout
cout
cout
}
void terminate()
{
pay=0;
taxrate=0;
empstatus="Salaried - Terminated";
}
};
class Contractor : public employee
{
public:
void calculatepay()
{
cout
cout
cout
}
void terminate()
{
pay=0;
empstatus="Contract Ended";
}
};
int main ()
{
int option, option1, option2, option3, numb4, numb5, numb6;
string employeeid;
float hours;
float pay;
float taxrate;
string empstatus;
int numHourly = 0;
int numSalaried = 0;
int numContractor = 0;
int const size = 10;
Hourly hourly[size];
Salaried salaried[size];
Contractor contractor[size];
employee hourly[size] = {{"AS101", 32.34, 28.50, 0.055},{"GH199", 44.5, 39.22, 0.04},{"UY189", 47.22, 45.60, 0.016},};
employee salaried[size] = {{"VE320", 45,750.34, 0.07},{"BR003", 65,740.88, 0.065},{"AA891", 50,900.71, 0.12},};
employee contractor[size] = {{"BV111", 55,473.56},{"NB290", 65,540.87},{"VC100", 45,679.25},};
employee *emp;
char ans = 'y';
while (ans == 'y')
{
system("cls");
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cin >> option;
switch(option)
{
case 1:
{
system("cls");
if (numHourly >= size)
{
cout
system("pause");
break;
}
emp = &hourly[numHourly];
while (option1!=5)
{
cout
cout
cout
cout
cout
cout
cout
cin >> option1;
switch (option1)
{
case 1:
cout
getline(cin, employeeid);
emp->setID(employeeid);
break;
case 2:
cout
cin >> hours;
emp->sethours(hours);
break;
case 3:
cout
cin >> pay;
emp->setpay(pay);
break;
case 4:
cout
cin >> taxrate;
emp->settaxrate(taxrate);
break;
case 5:
break;
}
}
numHourly++;
break;
}
case 2:
{
system("cls");
if (numSalaried >= size)
{
cout
system("pause");
break;
}
emp = &salaried[numSalaried];
while (option2!=4)
{
cout
cout
cout
cout
cout
cout
cin >> option2;
switch (option2)
{
case 1:
cout
getline(cin, employeeid);
emp->setID(employeeid);
break;
case 2:
cout
cin >> pay;
emp->setpay(pay);
break;
case 3:
cout
cin >> taxrate;
emp->settaxrate(taxrate);
break;
case 4:
break;
}
}
numSalaried++;
break;
}
case 3:
{
system("cls");
if (numContractor >= size)
{
cout
system("pause");
break;
}
emp = &contractor[numContractor];
while (option3!=4)
{
cout
cout
cout
cout
cout
cin >> option3;
switch (option3)
{
case 1:
cout
getline(cin, employeeid);
emp->setID(employeeid);
break;
case 2:
cout
cin >> pay;
emp->setpay(pay);
break;
case 3:
break;
}
}
numContractor++;
break;
}
case 4:
{
system("cls");
cout
cout
cout
cin >> numb4;
emp = &hourly[numb4];
emp->calculatepay();
getch;
break;
}
case 5:
{
system("cls");
cout
cout
cout
cin >> numb5;
emp = &salaried[numb5];
emp->calculatepay();
getch;
break;
}
case 6:
{
system("cls");
cout
cout
cout
cin >> numb6;
emp = &contractor[numb6];
emp->calculatepay();
getch;
break;
}
case 7:
{
system("cls");
cout
cin>>employeeid;
int i=0;
for(i=0;i { if(hourly[i].getid()==employeeid) hourly[i].terminate(); } if(i==numHourly) cout else cout break; } case 8: { system("cls"); cout cin>>employeeid; int i=0; for(i=0;i { if(salaried[i].getid()==employeeid) salaried[i].terminate(); } if(i==numSalaried) cout else cout break; } case 9: { system("cls"); cout cin>>employeeid; int i=0; for(i=0;i { if(contractor[i].getid()==employeeid) contractor[i].terminate(); } if(i==numContractor) cout else cout break; } case 10: { system("cls"); cout getch(); exit(0); break; } default: { cout cout getch(); break; } } } } Debugger ) X Buid log Build messages Cscope X File Llessage - Build file: "no targot" in "no project"(compile unknown)- In function int main) C:NUsers\39411\Desktop\CSCI15 CSCI15 Assignment_7 C:NUsers139411Desktop CScIlS CSCI15_Assignment _7--- 143 eror: conflicting declaration 'employee hourly [101' C:Users39411Desktop CSCI15 CScIi5 Assignment_7... 139 note: previous declaration as 'Hourly hourly [10] C:NUsers39411\DesktopiCsCI15 CSCI15 Assignmen 7.- 144 ezror: conflicting declaration 'employee salaried 1o] C:Users 39411Desktop CSCI15 CSCI15_Assignment_7... 140 note: previous declaration as 'Salaried salaried 101' C:Users 39411\Desktop CScI15 CSCI15 Assignment_7.-- 145 error: contiicting declaration 'employee contractor [10] C:Users 3s411Desktop CSCI1S CSCI15 assignment _7.-- 141 note: previous declaration as 'Contractor contractor [101' Build failed: 3 error(s), 0 warning(s) ?0 minute(s), second(S)) ? =.. CSC115 Assignment 7.cpp - Code:Blocks 17.12 File Edit View Search Project Build Debug Fortran wxSmith Tools Tools+ Plugins DoxyBlocks Settings Help main0: int CSCI15 Assignment 7.cpp X CSCI15 int main cpp 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 int option, optionl, option2, option3, numb4, numb5, numb6: string employeeid: float hours float pay: float taxrate: string empstatus: int numHourly-0; int numsalaried = 0; int numContractor = 0; int const size = 10; Hourly hourly[size] Salaried salaried[size]: Contractor contractor [size] employee employee employee hourly [size] = (("ASIOI", 32.34, 28.50, 0.055},{"GHI 99", 44.5, 39.22, 0.04), ("UY189", 47.22, 45.60, 0.016), }; salaried [size] {{"vE320", 45,750.34, ?.07},{"BR003", 65,740.88, 0.065},{"AAB 91 ", 50,900.71, 0.12), }; contractor [size] {{"Bill", 55, 473.56), { "NB2 90", 65, 540.87},{"VC100", 45,679.25),}; 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 1 60 employee emp char ansy while (ans'y' system("cls" cout Debugger ) X Buid log Build messages Cscope X File Llessage - Build file: "no targot" in "no project"(compile unknown)- In function int main) C:NUsers\39411\Desktop\CSCI15 CSCI15 Assignment_7 C:NUsers139411Desktop CScIlS CSCI15_Assignment _7--- 143 eror: conflicting declaration 'employee hourly [101' C:Users39411Desktop CSCI15 CScIi5 Assignment_7... 139 note: previous declaration as 'Hourly hourly [10] C:NUsers39411\DesktopiCsCI15 CSCI15 Assignmen 7.- 144 ezror: conflicting declaration 'employee salaried 1o] C:Users 39411Desktop CSCI15 CSCI15_Assignment_7... 140 note: previous declaration as 'Salaried salaried 101' C:Users 39411\Desktop CScI15 CSCI15 Assignment_7.-- 145 error: contiicting declaration 'employee contractor [10] C:Users 3s411Desktop CSCI1S CSCI15 assignment _7.-- 141 note: previous declaration as 'Contractor contractor [101' Build failed: 3 error(s), 0 warning(s) ?0 minute(s), second(S)) ? =
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
