#include <iostream.h>
#include <conio.h>
#include <stdio.h>
class employee
{
protected:
char employeeName [20];
char employeeIDNumber [10];
public:
employee();
void setEmployee();
void showEmployee();
};
employee::employee()
{
//Whatever
}
void employee::setEmployee()
{
cout << "Enter the employees name: ";
fgets(employeeName, 20, stdin);
cout << "Enter the employees ID number: ";
fgets(employeeIDNumber, 10, stdin);
}
void employee::showEmployee()
{
cout << "\nThe employees name is: " <<employeeName;
cout << "The employees ID number is: " << employeeIDNumber;
}
class staff:public employee
{
private:
float hours;
float rate;
float pay;
public:
staff();
void showEmployee();
void setEmployee();
void updateHrRt();
void computePay();
};
staff::staff()
{
//whatever
}
void staff::showEmployee()
{
cout << "\nThe employees name is: " <<employeeName;
cout << "The employees ID number is: " << employeeIDNumber;
}
void staff::setEmployee()
{
cout << "Enter the employees name: ";
fgets(employeeName, 20, stdin);
cout << "Enter the employees ID number: ";
fgets(employeeIDNumber, 10, stdin);
}
void staff::updateHrRt()
{
cout << "Input the new hourly rate: ";
cin >> rate;
cout << "Input the hours completed: ";
cin >> hours;
}
void staff::computePay()
{
cout << "Enter the amount of hours completed: ";
cin >> hours;
cout << "Enter the hourly rate: ";
cin >> rate;
if (hours > 40)
pay = ((hours - 40)*(rate * 1.5))+( 40*rate);
else
pay = rate * hours;
cout << "Your pay is: " << pay;
}
class faculty:public employee
{
private:
int rank;
float salary;
public:
faculty();
void showEmployee();
void setEmployee();
void updateRnk();
void computePay();
};
faculty::faculty()
{
//whatever
}
void faculty::showEmployee()
{
cout << "\nThe employees name is: " <<employeeName;
cout << "The employees ID number is: " << employeeIDNumber;
}
void faculty::setEmployee()
{
cout << "Enter the employees name: ";
fgets(employeeName, 20, stdin);
cout << "Enter the employees ID number: ";
fgets(employeeIDNumber, 10, stdin);
}
void faculty::updateRnk()
{
cout << "Please enter the new rank of " << employeeName;
cin >> rank;
}
void faculty::computePay()
{
switch(rank)
{
case 1:
salary = 250000;
cout << employeeName << ", your salary is: $" << salary;
break;
case 2:
salary = 200000;
cout << employeeName << ", your salary is: $" << salary;
break;
case 3:
salary = 120000;
cout << employeeName << ", your salary is: $" << salary;
break;
}
}
int main()
{
employee FBi;
faculty FB;
FBi.setEmployee();
FBi.showEmployee();
getch();
return 0;
}