Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Author: (James Mc Ginty <mcgintyj1@students.rowan.edu>)
- // Assignment: (C7 Lab-1 Types)
- // Description: (Enum gender, get gender enum and string, call struct , array of employee, output)
- // Comments (optional): T-Minus 3 weeks left
- #include "stdafx.h" // DO NOT PLACE ANY INCLUDES ABOVE HERE
- #include <iostream>
- #include <istream>
- #include <string>
- #include <cstdlib>
- #include <iomanip>
- #include <conio.h>
- #include <fstream>
- #include <windows.h>
- using namespace std;
- const int MAX = 5;
- struct Employee
- {
- string firstname;
- string lastname;
- string sex;
- float salary;
- };
- void getEmployee(Employee employee[], int i, bool& done);
- void printEmployee(Employee employee[], int i);
- int main() {
- struct Employee employee[MAX];
- bool done = false;
- for (int i = 0; i<MAX; i++) { //taking values from user
- if (done != true) {
- getEmployee(employee, i, done);
- }
- else {
- break;
- }
- }
- for (int i = 0; i < MAX; i++) { //printing values
- if (employee[i].firstname != "" && employee[i].lastname != "" && employee[i].sex != "") {
- printEmployee(employee, i);
- }
- }
- system("PAUSE");
- return 0;
- }
- void getEmployee(Employee employee[], int i, bool& done) {
- cout << "Employee " << i + 1 << endl;
- cout << "Enter Employee First Name: " << endl;
- cin >> employee[i].firstname;
- if (employee[i].firstname == "Z") {
- done = true;
- }
- cout << "Enter Employee Last Name: " << endl;
- cin >> employee[i].lastname;
- cout << "Enter Employee Sex: " << endl;
- cin >> employee[i].sex;
- cout << "Enter Employee Salary: " << endl;
- cin >> employee[i].salary;
- i++;
- system("CLS");
- }
- void printEmployee(Employee employee[], int i) {
- cout << "Employee " << i + 1 << endl;
- cout << "First Name: " << employee[i].firstname << endl;
- cout << "Last Name: " << employee[i].lastname << endl;
- cout << "Sex: " << employee[i].sex << endl;
- cout << "Salary: " << employee[i].salary << "\n\n" << endl;
- i++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement