Help me correct my C++ code please! Pictures included. My current code with the error picture; #include using namespace std; class Employee { public: string first_name; string last_name; int monthly_sal; Employee() { first_name=""; last_name=""; monthly_sal=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; } string getFirst_Name() { return first_name; } string getLast_Name() { return last_name; } int get_salary() { return monthly_sal; } int get_yearly_salary() { return 12*monthly_sal; } }; int main() { Employee ob; string first_name,last_name; int monthly_sal; cout<<"Enter: the employee's first and last name: "; cin>> last_name; cout<<"Enter: the employee's monthly salary: "; cin >> monthly_sal; cout<<"salary before the raise was 0" <
Help me correct my C++ code please! Pictures included. My current code with the error picture;
#include <iostream>
using namespace std;
class Employee
{
public:
string first_name;
string last_name;
int monthly_sal;
Employee()
{
first_name="";
last_name="";
monthly_sal=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;
}
string getFirst_Name()
{
return first_name;
}
string getLast_Name()
{
return last_name;
}
int get_salary()
{
return monthly_sal;
}
int get_yearly_salary()
{
return 12*monthly_sal;
}
};
int main()
{
Employee ob;
string first_name,last_name;
int monthly_sal;
cout<<"Enter: the employee's first and last name: ";
cin>> last_name;
cout<<"Enter: the employee's monthly salary: ";
cin >> monthly_sal;
cout<<"salary before the raise was 0" <<endl;
cout<<"yearly salary after the raise is 0" <<endl;
return 0;
}
![Problems Detected:
The contents of your standard output is incorrect.
Given the following was entered from the keyboard:
John Doed
|-23의
you displayed:
Enter: the employee's-first-and·last-name: Enter: the employee's monthly•salary: salary-before the•raise-was 0d
yearly salary•after•the-raise•is-0d
instead of:
Enter: the employee's first-and•last-name: Enter:•the employee's-monthly salary:-John Doe's•yearly-salary-before-the-raise was 0d
John-Doe's-yearly-salary-after•the-raise-is 0J
Failed 4 out of 4 test runs.
Failed Test Run #1
The contents of your standard output is incorrect.
Interactive Session - W v
Hide Invisibles
Highlight: None
Show Highlighted Only O
Expected Result:
Enter:John· Smithe
Your Code's Actual Result:
· the· employee's first·and -last-name: - Enter:100004
·the employee's monthly salary: John Smith's•yearly·salary.before the raise wa
John· Smith's.yearly salary·after the raise is:1320004
Enter:John- Smithe
-the employee's first·and - last name : · Enter:100004
-the employee 's monthly salary::salary·before the raise was:0e
yearly salary after the raise is:ed](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F1c4b0a35-b7ae-4682-9b93-5e61724ed9d4%2F000d778c-2f2b-4489-b824-2f3904edc0df%2Fxddrol_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)