Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program Name: Employee info
- //Programmer: Trevor England
- //Date: 1/17/16
- //Assignment: CIS247 Week 2 iLab
- //Program Description: Program inputs data from the user and then returns it using a class
- #include <iostream>
- #include <string>
- #include <stdlib.h>
- #include <iomanip>
- using namespace std;
- void DisplayDivider(string);
- string GetInput(string);
- class employee
- {
- private:
- string firstName,lastName;
- int empID, dependents;
- char gender;
- double annualSalary;
- public:
- //employee();
- //employee(string first, string last, int ID, char gen, int dep, double sal);
- double calcPay(){return annualSalary / 52;}
- void displayEmployee();
- string getFirstName(){return firstName;}
- void setFirstName(string first){firstName = first;}
- string getLastName(){return lastName;}
- void setLastName(string last){lastName = last;}
- int getEmpID(){return empID;}
- void setEmpID(int ID){empID = ID;}
- char getGender(){return gender;}
- void setGender(char gen){gender = gen;}
- int getDependents(){return dependents;}
- void setDependents(int dep){dependents = dep;}
- double getAnnualSalary(){return annualSalary;}
- void setAnnualSalary(double sal){annualSalary = sal;}
- };
- void employee::displayEmployee()
- {
- cout << "Name : " << firstName << " " << lastName << endl;
- cout << "Employee ID: " << empID << endl;
- cout << "Gender: " << gender << endl;
- cout << "Dependent: " << dependents << endl;
- cout << "Annual Salary: " << fixed << setprecision(2) << annualSalary << endl;
- cout << "Weekly Salary: " << fixed << setprecision(2) << calcPay() << endl;
- }
- void main()
- {
- string input, input1;
- DisplayDivider("Employee 1");
- cout << endl << endl ;
- employee employee1;
- input = GetInput("first name: ");
- cin >> input1;
- employee1.setFirstName(input1);
- cout << endl;
- input = GetInput("last name: ");
- cin >> input1;
- employee1.setLastName(input1);
- cout << endl;
- input = GetInput("employee's ID number: ");
- cin >> input1;
- employee1.setEmpID = atoi(input1.c_str());
- employee1.setEmpID(input1);
- cout << endl;
- input = GetInput("employee's gender as (M - Male, F - Female:");
- cin >> input1;
- employee1.setGender(input1);
- cout << endl;
- input = GetInput("number of dependents: ");
- cin >> input1;
- employee1.setDependents = atoi(input1.c_str());
- employee1.setDependents(input1);
- cout << endl;
- input = GetInput("annual salary: ");
- cin >> input1;
- employee1.setAnnualSalary = atof(input1.c_str());
- employee1.setAnnualSalary(input1);
- cout << endl;
- DisplayDivider("Employee Information");
- cout << endl;
- employee1.displayEmployee();
- DisplayDivider("Employee 2");
- cout << endl << endl;
- employee emp2;
- emp2.setFirstName("George");
- emp2.setLastName("Washington");
- emp2.setEmpID(12345);
- emp2.setGender('M');
- emp2.setDependents(2);
- emp2.setAnnualSalary(12000);
- DisplayDivider("Employee Information");
- emp2.displayEmployee();
- system("PAUSE");
- }
- void DisplayDivider(string title)
- {
- cout << "**************** "<< title << "****************\n";
- }
- string GetInput(string item)
- {
- string strInput;
- cout << "Please enter the " << item << endl;
- cin >> strInput;
- return strInput;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement