Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Employee {
- private:
- string name;
- string surname;
- int salary;
- public:
- Employee() { }
- Employee(string n, string s, int plata) {
- name = n;
- surname = s;
- salary = plata;
- }
- Employee(const Employee& e) {
- name = e.getName();
- surname = e.getSurname();
- salary = e.getSalary();
- }
- void setName(string s) {
- name = s;
- }
- void setSurname(string s) {
- surname = s;
- }
- void setSalary(int s) {
- salary = s;
- }
- string getName() const { return name; }
- string getSurname() const { return surname; }
- int getSalary() const { return salary; }
- void print() {
- cout << "Employee name: " << name << endl;
- cout << "Employee surname: " << surname << endl;
- cout << "Employee salary: " << salary << endl;
- }
- };
- class TechCompany {
- private:
- string name;
- Employee* employees;
- int numOfEmployees = 0;
- public:
- TechCompany() {
- name = "";
- employees = new Employee[100];
- numOfEmployees = 0;
- }
- TechCompany(string s, Employee* e, int n) {
- name = s;
- employees = e;
- numOfEmployees = n;
- }
- ~TechCompany() {
- delete employees;
- }
- string getName() {
- return name;
- }
- int getNumOfEmployees() {
- return numOfEmployees;
- }
- void print() {
- cout << "Tech company name: " << name << endl;
- cout << "Number of employees: " << numOfEmployees << endl;
- }
- double getAverageOfEmployeesSalary() {
- double result = 0;
- for (int i = 0; i < numOfEmployees; i++) {
- result += employees[i].getSalary();
- }
- return result / numOfEmployees;
- }
- };
- TechCompany printCompanyWithHighestAverageSalary(TechCompany companies[], int numCompanies) {
- int best_index = 0;
- for (int i = 0; i < numCompanies; i++) {
- if (companies[i].getAverageOfEmployeesSalary() > companies[best_index].getAverageOfEmployeesSalary()) {
- best_index = i;
- }
- }
- return companies[best_index];
- }
- int main() {
- // KE VI BIDE DADENA
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement