Question
I have this code written and I cant get it to run. Can anyone help? I have the Employee header and Source code done and
I have this code written and I cant get it to run. Can anyone help? I have the Employee header and Source code done and it says that everything is wrong in line 33 i think?
#include "Employee.h"
int main(){
cout << "Welcome to your first Object Oriented Program==Employee ClassCIS247C, Week 1 Lab" << endl;
cout << "Name: Alejandra Dominguez-Cuevas" << endl;
cout << "************** Employee 1 **************" << endl;
Employee emp; //1. Create an Employee object using the default constructor
string first;
string last;
string gen;
string dependents ;
string salary ;
cout << "Please enter your First name " ;
cin >> first;
cout << "Please enter your Last name " ;
cin >> last;
cout << "Please enter your Gender " ;
cin >> gen;
cout << "Please enter your Dependents " ;
cin >> dependents;
cout << "Please enter your Annual Salary " ;
cin >> salary;
emp.setFirstName(first);
emp.setLastName(last);
emp.setDependents(atoi(dependents.c_str()));
emp.setAnnualSalary(atof(salary.c_str()));
if (gen == "Female"){
emp.setGender('F');
}
else if (gen == "Male"){
emp.setGender('M');
}
else{
emp.setGender('U');
}
emp.displayEmployee();
//6. Create a second Employee object using the multi-argument constructor, setting each of the attributes with appropriate valid values
cout << "************** Employee 2 **************" << endl;
Employee emp2("Dominguez-Cuevas", "Alejandra", 'D', 5, 24000.0);
emp2.displayEmployee();
cout << "The end of the CIS247C Week3 iLab" << endl;
system("pause");
return 0;
}
#include "Employee.h"
#include
#include
#include
#include
int Employee::numEmployee=0;
Employee::Employee()
{
firstName = "not given";
lastName = "not given";
gender = 'U';
dependents = 0;
annualSalary = 20000;
numEmployee++;
}
Employee::Employee(string first, string last, char gen, int dep, double salary){
firstName = first;
lastName = last;
gender = gen;
dependents = dep;
annualSalary = salary;
numEmployee++;
}
string Employee::getFirstName(){
return firstName;
}
void Employee::setFirstName(string first){
firstName = first;
}
string Employee::getLastName()
{
return lastName;
}
void Employee::setLastName(string last){
lastName = last;
}
char Employee::getGender(){
return gender;
}
void Employee::setGender(char gen){
gender = gen;
}
int Employee::getDependents(){
return dependents;
}
void Employee::setDependents(int dep){
dependents = dep;
}
double Employee::getAnnualSalary(){
return annualSalary;
}
void Employee::setAnnualSalary(double salary){
annualSalary = salary;
}
double Employee::calculatePay(){
return (annualSalary / 52);
}
void Employee::displayEmployee(){
cout << "Employee Information" << endl;
cout << "----------------------------------------------------------------------------" << endl;
cout << setw(16) << left << "Name:" << firstName << " " << lastName << endl;
cout < cout << setw(16) <<"Dependents:" << dependents << endl; cout << setw(16) << fixed << setprecision(2) << "Annual Salary:" << annualSalary << endl; cout << setw(16) << "Weekly Salary:" < } // Employee.h #ifndef Employee_h #define Employee_h #include #include using namespace std; #pragma once class Employee { public: Employee(); Employee(string first, string last, char gen, int dep, double salary); double calculatePay(); void displayEmployee(); string getFirstName(); void setFirstName(string first); string getLastName(); void setLastName(string last); char getGender(); void setGender(char gen); int getDependents(); void setDependents(int dep); double getAnnualSalary(); void setAnnualSalary(double salary); private: string firstName; string lastName; char gender; int dependents; double annualSalary; static int numEmployee; }; #endif /* Employee_h */
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started