here is question.. 2) Create an employee_class that contains an employee\'s firs
ID: 3620991 • Letter: H
Question
here is question..
2) Create an employee_class that contains an employee's
first and last name, their phone number and their yearly salary.
Create class member functions to update the employee's phone number,
change their salaries, provide the total yearly salaries,
and list all the employees in the company.
Starting with the functionality of employee class, create separate
class instance for each office (based on the phone prefix, 863- and
568-) and one for the consultant. Create friend functions that
allow us to work with all the employees in all the different offices.
Create friend functions that lists all of the employees in
the company and determine the total salary expenditures across the
company. We also need a friend function that can list all the
employees with salaries over an input value - i.e. "list all employees
with salaries more than xxxxx ".
Here is the employee list...:
name phone salary
Jill Jones, 5681122, 45000
Steve Smith, 5686745, 38000
Fred Friendly, 8634232, 51000
Amanda Andrews, 8639845, 28000
Mike Myers, 3529257, 68000
Pete Piper, 5683425, 35000
Tina Turner, 5684455, 53500
Vera Veldez, 8636683, 42000
Zack Zip, 8638988, 36000
Chad Chumley, 8638443, 32000
The company as a whole has only one exposition
projector and setup (the 'demo-kit' as it is known) for
folks use to make presentations to potential customers at
conferences, meetings, expos, etc. You need to modify your
your employee class to create a company-wide 'check-out' function
for the demo-kit. Any offices can check out the demo-kit,
see if the demo-kit is available or not and who has it.
-----------------------------------------------------------------------------
here is my code. is this what they want or do i need to work more on something?
#include
using namespace std;
class employee{ // class employee
public:
employee(char ifirst[], char ilast[], int iphone, int isalary); // Array (first name, Last name, phone number, salary)
void update_phone(int iphone); // change phone number
void update_salary(int isalary); // change salary
void show_list(); // five lists
int return_salary();
int compare(char ifirst[]);
private:
char first[20]; // first name
char last[20]; // last name
int phone; // phone number
int salary; // salary
};
employee::employee(char ifirst[], char ilast[], int iphone, int isalary){ // Array
strcpy(first, ifirst);
strcpy(last, ilast);
phone = iphone;
salary = isalary;
}
//
int employee::compare(char ifrist[]){
return strcmp(ifrist, first);
}
int employee::return_salary(){
return salary;
}
void employee::show_list(){
cout << first <<" "<< last <<" "<< phone <<" "<< salary << endl;
}
void employee::update_phone(int iphone){
phone = iphone;
}
void employee::update_salary(int isalary){
salary = isalary;
}
void main(){
int i, input=0, sum=0, phone, salary;
char name[20];
//employee data
employee data[10] = {employee("Jill", "Jones", 5681122, 45000),
employee("Steve", "Smith", 5686745, 38000),
employee("Pete", "Piper", 5683425, 35000),
employee("Tina", "Turner", 5684455, 53500),
employee("Fred", "Friendly", 8634232, 51000),
employee("Amanda", "Andrews", 8639845, 28000),
employee("Vera", "Veldez", 8636683, 42000),
employee("Zack", "Zip", 8638988, 36000),
employee("Chad", "Chumley", 8638443, 32000),
employee("Mike", "Myers", 3529257, 68000)
};
while(input!=6){
cout << "----- Select -----" << endl;
cout << "1. Print List " << "2. Change Phone_number " << "3. Change Salary " << "4. Total Salary " << "5. exit ";
cin >> input;
switch(input){
case 1: // list #1
cout << "------Employee_ List------- ";
for(i=0; i<10; i++)
data[i].show_list();
cout << endl;
break;
case 2: // list #2. change phone number
cout << "input first name and new phone_number" <cin >> name;
cin >> phone;
for(i=0; i<10; i++){
if(data[i].compare(name)==0)
data[i].update_phone(phone);
}
break;
case 3: // linst #3. change salary
cout << "input first name and new salary" <cin >> name;
cin >> salary;
for(i=0; i<10; i++){
if(data[i].compare(name)==0)
data[i].update_salary(salary);
}
break;
case 4: // The total salary
for(i=0; i<10; i++)
sum += data[i].return_salary(); // add data of salaries
cout << "Total Salary : " << sum <break;
case 5: // exit program
cout << "Program Exit" <break;
default : // error
cout << "input error" << endl;
break;
}
}
}
Explanation / Answer
please rate - thanks
you asked to comment but I've also made a few verry minor corrections to what you did. all but one may have been the cramster editor. I have indicated those changes in red
I've then annotated your assignment. you are missing quite a bit, but feel you are totally capable of doing it yourself
hope this is what you are looking for
2) Create an employee_class that contains an employee's
first and last name, their phone number and their yearly salary.
Create class member functions to update the employee's phone number,
change their salaries, provide the total yearly salaries,
and list all the employees in the company.
not done
Starting with the functionality of employee class, create separate
class instance for each office (based on the phone prefix, 863- and
568-) and one for the consultant.
not done
Create friend functions that
allow us to work with all the employees in all the different offices.
done but not as friend function
Create friend functions that lists all of the employees in
the company and determine the total salary expenditures across the
company.
not done
We also need a friend function that can list all the
employees with salaries over an input value - i.e. "list all employees
with salaries more than xxxxx ".
Here is the employee list...:
name phone salary
Jill Jones, 5681122, 45000
Steve Smith, 5686745, 38000
Fred Friendly, 8634232, 51000
Amanda Andrews, 8639845, 28000
Mike Myers, 3529257, 68000
Pete Piper, 5683425, 35000
Tina Turner, 5684455, 53500
Vera Veldez, 8636683, 42000
Zack Zip, 8638988, 36000
Chad Chumley, 8638443, 32000
The company as a whole has only one exposition
projector and setup (the 'demo-kit' as it is known) for
folks use to make presentations to potential customers at
conferences, meetings, expos, etc. You need to modify your
your employee class to create a company-wide 'check-out' function
for the demo-kit. Any offices can check out the demo-kit,
see if the demo-kit is available or not and who has it.
#include <iostream>
using namespace std;
class employee{ // class employee
public:
employee(char ifirst[], char ilast[], int iphone, int isalary); // Array (first name, Last name, phone number, salary)
void update_phone(int iphone); // change phone number
void update_salary(int isalary); // change salary
void show_list(); // five lists
int return_salary();
int compare(char ifirst[]);
private:
char first[20]; // first name
char last[20]; // last name
int phone; // phone number
int salary; // salary
};
employee::employee(char ifirst[], char ilast[], int iphone, int isalary){ // Array
strcpy(first, ifirst);
strcpy(last, ilast);
phone = iphone;
salary = isalary;
}
//
int employee::compare(char ifrist[]){
return strcmp(ifrist, first);
}
int employee::return_salary(){
return salary;
}
void employee::show_list(){
cout << first <<" "<< last <<" "<< phone <<" "<< salary << endl;
}
void employee::update_phone(int iphone){
phone = iphone;
}
void employee::update_salary(int isalary){
salary = isalary;
}
int main(){
int i, input=0, sum=0, phone, salary;
char name[20];
//employee data
employee data[10] = {employee("Jill", "Jones", 5681122, 45000),
employee("Steve", "Smith", 5686745, 38000),
employee("Pete", "Piper", 5683425, 35000),
employee("Tina", "Turner", 5684455, 53500),
employee("Fred", "Friendly", 8634232, 51000),
employee("Amanda", "Andrews", 8639845, 28000),
employee("Vera", "Veldez", 8636683, 42000),
employee("Zack", "Zip", 8638988, 36000),
employee("Chad", "Chumley", 8638443, 32000),
employee("Mike", "Myers", 3529257, 68000)
};
while(input!=5){
cout << "----- Select -----" << endl;
cout << "1. Print List " << "2. Change Phone_number " << "3. Change Salary " << "4. Total Salary " << "5. exit ";
cin >> input;
switch(input){
case 1: // list #1
cout << "------Employee_ List------- ";
for(i=0; i<10; i++)
data[i].show_list();
cout << endl;
break;
case 2: // list #2. change phone number
cout << "input first name and new phone_number " <cin >> name;
cin >> phone;
for(i=0; i<10; i++){
if(data[i].compare(name)==0)
data[i].update_phone(phone);
}
break;
case 3: // linst #3. change salary
cout << "input first name and new salary " <cin >> name;//////////////////
cin >> salary;
for(i=0; i<10; i++){
if(data[i].compare(name)==0)
data[i].update_salary(salary);
}
break;
case 4: // The total salary
for(i=0; i<10; i++)
sum += data[i].return_salary(); // add data of salaries
cout << "Total Salary : " << sum <<endl;
break;
case 5: // exit program
cout << "Program Exit" <<endl;
break;
default : // error
cout << "input error" << endl;
break;
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.