1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
|
#include<iostream>
#include<string>
#include<stdlib.h>
#include<iomanip>
using namespace std;
class Employee
{
private:
string firstName;
string lastName;
char gender;
int dependents;
double annualSalary;
public:
Employee();
Employee(string firstName, string lastName, char gender, int dependents, double salary);
double calculatePay(double);
void displayEmployee(void);
string getFirstName(string firstName);
string setFirstName(string);
string getLastName(string);
string setLastName( string);
char getGender(char);
char setGender( char);
int getDependents(int);
int setDependents( int);
double getAnnualSalary();
double setAnnualSalary( double);
Employee::Employee(void)
{
string firstName= "not given" ;
string lastName = "not given";
char gender = 'U';
int dependents = 0;
double annualSalary = 20000;
}
Employee::~Employee(void)
{
}
void setGender(char gen)
{
switch(gen)
{
case'f': case 'F': case 'm':case 'M': gender = gen; break;
default: cout << " Gender unknown" << endl; break;
default = Default_Gender;
}
}
Employee:: Employee(string firstName, string lastName, char gender, int dependents, double salary)
{
this ->firstName = firstName;
this ->lastName = lastName;
this ->gender = gender;
this ->dependents = dependents;
this ->annualSalary = salary;
string Employee::getFirstName()
{
cout << " Please enter first name:" << endl;
getline(cin,firstName);
return firstName;
}
void Employee::setFirstName(string name)
{
firstName = name;
}
string Employee::getLastName()
{
cout << "Please enter last name:" << endl;
getline(cin, lastName);
return lastName;
}
void Employee::setLastName(string name)
{
lastName= name;
}
char Employee::getGender()
{
cout << " Please enter gender:" << endl;
getline(cin, gender);
return gender;
}
void Employee::setGender(char gen)
{
gender = gen;
}
int Employee::getDependents()
{
cout << " Please enter the amount of dependents:" << endl;
getline(cin,dependents);
return dependents;
}
void Employee::setDependents(int dep)
{
dependents= dep;
}
double Employee::getAnnualSalary()
{
cout << " Please enter the employee's annual salary:" << endl;
getline(cin, annualSalary);
return annualSalary;
}
void Employee::setAnnualSalary(double salary)
{
annualSalary = salary;
}
double Employee::calculatePay()
{
annualSalary = annualSalary / 52;
return annualSalary;
}
}
};
int main()
{
string GetInput(string);
void setGender(char gen);
string DisplayDivider(string);
DisplayApplicationInformation();
Employee employee1;
employee1.setFirstName(GetInput("First Name"));
name = GetInput("First Name");
employee1.setLastName(GetInput("Last Name"));
name = GetInput("Last Name");
employee1.setGender(GetInput(char gen));
gender = gen;
employee1.setDependents(GetInput(int dep));
dependents = dep;
employee1.setAnnualSalary(GetInput(double salary));
double annualSalary = salary;
employee2.setFirstName(GetInput("First Name"));
name = GetInput("First Name");
employee2.setLastName(GetInput("Last Name"));
name = GetInput("Last Name");
employee2.setGender(GetInput(char gen));
gender = gen;
employee2.setDependents(GetInput(int dep));
dependents = dep;
employee2.setAnnualSalary(GetInput(double salary));
double annualSalary = salary;
cin.ignore();
return 0;
system("pause");
}
void DisplayApplicationInformation();
{
cout << " Welcome to the Employee Class Program!"<< endl;
cout << " CIS 247 Week 2 Lab" << endl;
cout << " Name: Alicia Shorts." << endl;
cout << " This program accepts employee information and calculates annual salary." << endl;
}
void displayEmployee()
{
cout << "Employee Information \n";
cout << " ____________________________________________________________________________________________________ \n";
cout << "Name: \t\t" << firstName << " " << lastName << "\n";
cout << " Gender: \t\t" << gender << "\n";
cout << "Dependents: \t" << dependents << "\n";
cout << "Annual Salary: \t" << setprecision(2) << showpoint << fixed << annualSalary << "\n";
cout << "Weekly Salary: \t" << setprecision(2) << showpoint << fixed << calculatePay();
}
string DisplayDivider( string outputTitle)
{
cout << "*********************************" << outputTitle<< "***************************************" << endl;
return outputTitle;
}
string GetInput(string)
{
string myString;
cout << " Please enter your" << inputType;
getline(cin,myString);
return myString;
}
|