#include #include #include using namespace std; class person { public: string fname, lname; double salary; string dept; person(string f, string l, double s, string d); void print(); }; person::person(string f, string l, double s, string d) { fname = f; lname = l; salary = s; dept = d; }; void person::print() { cout << fname << " " << lname << " of " << dept << ", $" << salary << "\n"; } vector employees; void add_employee(string f, string l, double s, string d) { person * p = new person(f, l, s, d); employees.push_back(p); } void list_employees() { for (int i = 0; i < employees.size(); i += 1) employees[i]->print(); } person * find_employee(string name) { for (int i = 0; i < employees.size(); i += 1) if (employees[i]->fname == name || employees[i]->lname == name) return employees[i]; return NULL; } int main() { add_employee("Mary", "Marlowe", 123456.00, "Management"); add_employee("Dennis", "Dog", 54321.50, "Design"); add_employee("Eric", "Earwig", 34567.75, "Engineering"); add_employee("Tammy", "Teapot", 23500.00, "Tetrahedrons"); add_employee("Francine", "Frogge", 168742.50, "Management"); add_employee("Geoffrey", "Georaffe", 21005.99, "Geography"); add_employee("Lolita", "Lambchop", 25300.00, "Lighting"); add_employee("Indiana", "Impediment", 1500.00, "Intern"); add_employee("Germania", "Gastropod", 47299.99, "Geography"); add_employee("Olivia", "Ointment", 25000000.00, "Owner"); string cmd; while (true) { cout << "> "; cin >> cmd; if (cmd == "list") list_employees(); else if (cmd == "find") { string qname; cin >> qname; person * p = find_employee(qname); if (p == NULL) cout << "Not found\n"; else p->print(); } else if (cmd == "raise") { string qname; double pct; cin >> qname >> pct; person * p = find_employee(qname); if (p == NULL) cout << "Not found\n"; else { p->print(); p->salary *= 1.0 + pct / 100.0; p->print(); } } else if (cmd == "exit") break; else cout << "command '" << cmd << "' not recognised\n"; } }