Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. // Author: (James Mc Ginty <mcgintyj1@students.rowan.edu>)
  2. // Assignment: (C7 Lab-1 Types)
  3. // Description: (Enum gender, get gender enum and string, call struct , array of employee, output)
  4. // Comments (optional): T-Minus 3 weeks left
  5.  
  6. #include "stdafx.h" // DO NOT PLACE ANY INCLUDES ABOVE HERE
  7. #include <iostream>
  8. #include <istream>
  9. #include <string>
  10. #include <cstdlib>
  11. #include <iomanip>
  12. #include <conio.h>
  13. #include <fstream>
  14. #include <windows.h>
  15.  
  16. using namespace std;
  17.  
  18. const int MAX = 5;
  19.  
  20. struct Employee
  21. {
  22. string firstname;
  23. string lastname;
  24. string sex;
  25. float salary;
  26. };
  27.  
  28. void getEmployee(Employee employee[], int i, bool& done);
  29. void printEmployee(Employee employee[], int i);
  30.  
  31. int main() {
  32.  
  33. struct Employee employee[MAX];
  34.  
  35. bool done = false;
  36.  
  37. for (int i = 0; i<MAX; i++) { //taking values from user
  38. if (done != true) {
  39. getEmployee(employee, i, done);
  40. }
  41. else {
  42. break;
  43. }
  44. }
  45.  
  46. for (int i = 0; i < MAX; i++) { //printing values
  47. if (employee[i].firstname != "" && employee[i].lastname != "" && employee[i].sex != "") {
  48. printEmployee(employee, i);
  49. }
  50. }
  51.  
  52. system("PAUSE");
  53.  
  54. return 0;
  55. }
  56.  
  57. void getEmployee(Employee employee[], int i, bool& done) {
  58. cout << "Employee " << i + 1 << endl;
  59. cout << "Enter Employee First Name: " << endl;
  60. cin >> employee[i].firstname;
  61. if (employee[i].firstname == "Z") {
  62. done = true;
  63. }
  64. cout << "Enter Employee Last Name: " << endl;
  65. cin >> employee[i].lastname;
  66. cout << "Enter Employee Sex: " << endl;
  67. cin >> employee[i].sex;
  68. cout << "Enter Employee Salary: " << endl;
  69. cin >> employee[i].salary;
  70. i++;
  71. system("CLS");
  72. }
  73.  
  74. void printEmployee(Employee employee[], int i) {
  75. cout << "Employee " << i + 1 << endl;
  76. cout << "First Name: " << employee[i].firstname << endl;
  77. cout << "Last Name: " << employee[i].lastname << endl;
  78. cout << "Sex: " << employee[i].sex << endl;
  79. cout << "Salary: " << employee[i].salary << "\n\n" << endl;
  80. i++;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement