May 23, 2015 at 4:26pm UTC
#include <iostream>
#include <string>
#include <iomanip>
#include <stdexcept>
#include <sstream>
using namespace std;
class Employee
{
private:
string firstName;
string lastName;
char gender;
int dependents;
double annualSalary;
public:
Employee();
Employee(string, string, char, int, double);
double calculatePay();
void displayEmployee();
string getFirstName();
string setFirstName(string);
string getLastName();
string setLastName(string);
char getGender();
void setGender(char);
int getDependents();
int setDependents(int);
double getAnnualSalary();
double setAnnualSalary(double);
void DisplayApplicationInformation();
void DisplayDivider(string);
string GetInput(string);
void TerminateApplication();
};
Employee::Employee()
{
firstName = "Not given";
lastName = "Not given";
gender = ('U');
dependents = 0;
annualSalary = 20000;
};
Employee::Employee(string first, string last, char gen, int depends, double anSalary)
{
firstName = first;
lastName = last;
gender = gen;
dependents = depends;
annualSalary = annualSalary;
};
string Employee::getFirstName()
{
return firstName;
}
string Employee::setFirstName(string)
{
return firstName;
}
string Employee::getLastName()
{
return lastName;
}
string Employee::setLastName(string)
{
return lastName;
}
char Employee::getGender()
{
return gender;
}
void Employee::setGender(char)
{
gender = gender;
}
int Employee::getDependents()
{
return dependents;
}
int Employee::setDependents(int)
{
return dependents;
}
double Employee::getAnnualSalary()
{
return annualSalary ;
}
double Employee::setAnnualSalary(double)
{
return annualSalary;
}
void Employee::displayEmployee()
{
cout << "Employee Name: " << firstName << " "<< lastName << endl;
cout << "Employee Gender: " << gender << endl;
cout << "Employee Dependents: " << dependents << endl;
cout << "Empoyee Annual Salary: " << annualSalary << endl;
cout << "Annual Salary:\t" << setprecision(2) << showpoint << fixed << annualSalary << "\n";
cout << "Employee Weekly Salary: " << annualSalary/52 << endl << endl;
};
double Employee::calculatePay()
{
return annualSalary/52;
};
void DisplayApplicationInformation()
{
cout << "Welcome the Basic User Interface Program" << endl;
cout << "CIS247, Week 2 Lab" << endl;
cout << "Name: Alicia Long" << endl << endl;
};
void DisplayDivider(string outputTitle)
{
cout << "**********"<< outputTitle << "**********" << endl << endl;
};
string GetInput(string inputType)
{
string strInput;
cout << "Enter the Employee " << inputType << endl;
cin >> strInput;
return strInput;
}
void TerminateApplication()
{
cout << "Thank you for using the Basic User Interface program" << endl;
}
void main()
{
DisplayApplicationInformation();
DisplayDivider("Employee 1");
Employee Employee1;
string firstName = GetInput("First Name");
Employee1.setFirstName(firstName);
string lastName = GetInput("Last Name");
Employee1.setLastName(lastName);
string dependents = GetInput("Dependent");
dependents = atoi(dependents.c_str());
Employee1.setDependents(dependents);
string annualSalary = GetInput("Annual Salary");
annualSalary = atof(annualSalary.c_str());
Employee1.setAnnualSalary(annualSalary);
Employee1.displayEmployee();
TerminateApplication();
}
May 23, 2015 at 5:39pm UTC
THANK U SO MUCH!!!!!I really appreciated it