Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include"Problem3.h"
  2.  
  3. Employee::Employee(std::string x, std::string y, int z)
  4. {
  5. firstName = x;
  6. lastName = y;
  7. pay = z;
  8. }
  9. Employee::Employee()
  10. {
  11. firstName = "John";
  12. lastName = "Smith";
  13. pay = 40000;
  14. }
  15. void Employee::setInfo(std::string x, std::string y, int z)
  16. {
  17. firstName = x;
  18. lastName = y;
  19. pay = z;
  20. }
  21. void Employee::getInfo()
  22. {
  23. std::cout << firstName << " " << lastName << " (" << pay << ")" << std::endl;
  24. }
  25. void EmployeeAdd(Employee * x, int n);
  26. void EmployeePrint(Employee * x, int n);
  27.  
  28. int main()
  29. {
  30. int numEmployees = -1;
  31. while (numEmployees < 1)
  32. {
  33. std::cout << "Number of Employees: ";
  34. std::cin >> numEmployees;
  35. }
  36. Employee * employees = new Employee[numEmployees];
  37. EmployeeAdd(employees, numEmployees);
  38. EmployeePrint(employees, numEmployees);
  39. system("pause");
  40. return 0;
  41. }
  42. void EmployeeAdd(Employee * x, int n)
  43. {
  44. for (int i = 0; i < n; i++)
  45. {
  46. std::string firstname, lastname;
  47. int pay;
  48. std::cout << "Employee " << i + 1 << std::endl;
  49. std::cout << "First Name: ";
  50. std::cin >> firstname;
  51. std::cout << "Last Name: ";
  52. std::cin >> lastname;
  53. std::cout << "Pay: ";
  54. std::cin >> pay;
  55. x[i].setInfo(firstname, lastname, pay);
  56. }
  57. }
  58. void EmployeePrint(Employee * x, int n)
  59. {
  60. std::cout << "Employees: " << std::endl << std::endl;
  61. for (int i = 0; i < n; i++)
  62. {
  63. x[i].getInfo();
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement