C++ Help me fix my code please! I'm missing something and can't figure it out. Code and error picture are below. #include using namespace std; class Employee { public: string first_name; string last_name; int monthly_sal; int increment; Employee() { first_name=""; last_name=""; monthly_sal=0; increment=0; } void setFirst_Name(string first_name) { this->first_name=first_name; } void setLast_Name(string last_name) { this->last_name=last_name; } void setSal(int monthly_sal) { if(monthly_sal<0) this->monthly_sal=0; this->monthly_sal=monthly_sal; } void setInc(int increment) { monthly_sal += increment; } string getFirst_Name() { return first_name; } string getLast_Name() { return last_name; } int get_salary() { return monthly_sal; } int get_increment() { return increment; } int get_yearly_salary_before() { return 12*monthly_sal; } int get_yearly_salary_after() { return 12*(monthly_sal+increment); } }; int main() { Employee ob; ob.increment = 1000; string first_name,last_name; cout<<"Enter: the employee's first and last name: "; cin>> first_name >> last_name; cout<<"Enter: the employee's monthly salary: "; cin >> ob.monthly_sal; cout<< first_name << " " <
C++ Help me fix my code please! I'm missing something and can't figure it out. Code and error picture are below.
#include <iostream>
using namespace std;
class Employee
{
public:
string first_name;
string last_name;
int monthly_sal;
int increment;
Employee()
{
first_name="";
last_name="";
monthly_sal=0;
increment=0;
}
void setFirst_Name(string first_name)
{
this->first_name=first_name;
}
void setLast_Name(string last_name)
{
this->last_name=last_name;
}
void setSal(int monthly_sal)
{
if(monthly_sal<0)
this->monthly_sal=0;
this->monthly_sal=monthly_sal;
}
void setInc(int increment)
{
monthly_sal += increment;
}
string getFirst_Name()
{
return first_name;
}
string getLast_Name()
{
return last_name;
}
int get_salary()
{
return monthly_sal;
}
int get_increment()
{
return increment;
}
int get_yearly_salary_before()
{
return 12*monthly_sal;
}
int get_yearly_salary_after()
{
return 12*(monthly_sal+increment);
}
};
int main()
{
Employee ob;
ob.increment = 1000;
string first_name,last_name;
cout<<"Enter: the employee's first and last name: ";
cin>> first_name >> last_name;
cout<<"Enter: the employee's monthly salary: ";
cin >> ob.monthly_sal;
cout<< first_name << " " <<last_name <<"'s yearly salary before the raise was "<< ob.get_yearly_salary_before() <<endl;
cout<<first_name << " " << last_name <<"'s yearly salary after the raise is "<< ob.get_yearly_salary_after() <<endl;
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images