#include #include using namespace std; class person { public: string fname, lname; double salary; string dept; person(string f, string l, double s, string d) { fname = f; lname = l; salary = s; dept = d; } void print() { cout << fname << " " << lname << ", of " << dept << ", $" << salary << " per year\n"; } }; const int max_emps = 100; person * employee[max_emps]; int num_emps = 0; void add_employee(person * p) { if (num_emps >= max_emps) { cerr << "Too many employees, not added\n"; return; } employee[num_emps] = p; cout << "OK, added " << num_emps << ": "; employee[num_emps]->print(); num_emps += 1; } void list_employees() { for (int i = 0; i < num_emps; i += 1) { cout << i << ": "; employee[i]->print(); } } person * find_employee(string lastname) { for (int i = 0; i < num_emps; i += 1) if (employee[i]->lname == lastname) return employee[i]; return NULL; } void give_ten_percent(string name) { person * p = find_employee(name); if (p == NULL) { cerr << "Search failed\n"; return; } cout << "previous salaray = " << p->salary << "\n"; p->salary *= 1.10; cout << "OK, salaray = " << p->salary << "\n"; } int main() { add_employee(new person("Mary", "Marlowe", 123456.00, "Management")); add_employee(new person("Dennis", "Dog", 54321.50, "Design")); add_employee(new person("Eric", "Earwig", 34567.75, "Engineering")); add_employee(new person("Tammy", "Teapot", 23500.00, "Tetrahedrons")); add_employee(new person("Francine", "Frogge", 168742.50, "Management")); add_employee(new person("Geoffrey", "Georaffe", 21005.99, "Geography")); add_employee(new person("Lolita", "Lambchop", 25300.00, "Lighting")); add_employee(new person("Indiana", "Impediment", 1500.00, "Intern")); add_employee(new person("Germania", "Gastropod", 47299.99, "Geography")); add_employee(new person("Olivia", "Ointment", 25000000.00, "Owner")); string cmd; while (true) { cout << "> "; cin >> cmd; if (cmd == "list") list_employees(); else if (cmd == "find") { string who; cin >> who; person * p = find_employee(who); if (p == NULL) cout << "Not found\n"; else p->print(); } else if (cmd == "raise") { string who; cin >> who; give_ten_percent(who); } else if (cmd == "exit") break; else cerr << "command '" << cmd << "' not recognised\n"; } }