Question: Please correct this code so that the user will input Employee and B first name, last name, as well as beginning salary. For some reason
Please correct this code so that the user will input Employee and B first name, last name, as well as beginning salary. For some reason it just prints out the triple letters I used and does not allow for input. Please provide a copyable text code as well as a screenshot of the output where you are entering the variables requested for a quick thumbs up.
//3_11.cpp
#include
#include
using namespace std;
class Employee
{
public:
//CLASS CONTRUCTOR
Employee(string firstname, string lastname, int salary)
{
setFirstname(firstname);
setLastname(lastname);
setMonthlysalary(salary);
}
//FUNCTIONS FOR NAME AND SALARY
void setFirstname(string firstname)
{
first_name=firstname;
}
void setLastname(string lastname)
{
last_name=lastname;
}
void setMonthlysalary(int salary)
{
if (salary <= 0)
salary = 0;
if (salary > 0)
monthly_salary=salary;
}
string getFirstname()
{
return first_name;
}
string getLastname()
{
return last_name;
}
int getMonthlysalary()
{
return monthly_salary;
}
private:
string first_name, last_name;
int monthly_salary;
};
int main()
{
int yearly_salary, salary_raise, salary_revised;
//EMPLOYEE OBJECTS
Employee employeeA("AAA","BBB",5000);
Employee employeeB("CCC","DDD",4500);
cout <<"Employee A First Name: " << employeeA.getFirstname() < cout <<"Employee A Last Name: " << employeeA.getLastname() << endl; cout <<"Employee A Monthly Salary: " << employeeA.getMonthlysalary() < cout <<"Employee B First Name: " << employeeB.getFirstname() < cout <<"Employee B Last Name: " << employeeB.getLastname() << endl; cout <<"Employee B Monthly Salary: " << employeeB.getMonthlysalary() < yearly_salary = 12* employeeA.getMonthlysalary(); cout << "Employee A Yearly Salary: " << yearly_salary < yearly_salary = 12* employeeB.getMonthlysalary(); cout << "Employee B Yearly Salary: " << yearly_salary < cout << " "; salary_raise = (10 * employeeA.getMonthlysalary())/100; salary_revised = (salary_raise+employeeA.getMonthlysalary())/12; employeeA.setMonthlysalary(salary_revised); cout<< "Employee updated salary: " < //repeat for employee B salary_raise = (10 * employeeB.getMonthlysalary())/100; salary_revised = (salary_raise+employeeB.getMonthlysalary())/12; employeeB.setMonthlysalary(salary_revised); cout<< "Employee updated salary: " < system("pause"); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
