Create a class called Employee that includes three data members: a first name (type string), a last name (type string), and monthly salary (type int). The class will have a constructor that initializes the three data members. Include the set and get member functions for each data member. If the monthly salary is not positive, the set function will set it to 0. Also include a member function that returns the yearly salary (i.e. twelve times the monthly salary). Write a test program that prompts the user to enter the first and last name of an employee as well as their monthly salary. The program will then output the yearly salary of the employee, give them a 10 percent raise, and output the yearly salary again.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

C++ Help me fix my code please! I'm missing something and can't figure it out. Code and error picture are below. Original question is in the pictures too.

#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;
        }
        else{
        this->monthly_sal=monthly_sal;
        }
    }
    void setInc(int increment)
    {
        monthly_sal =monthly_sal+(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+(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;
  ob.setSal(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;
}

Create a class called Employee that includes three data members: a first
name (type string), a last name (type string), and monthly salary (ty.pe int).
The class will have a constructor that initializes the three data members.
Include the set and get member functions for each data member. If the monthly
salary is not positive, the set function will set it to 0. Also include a
member function that returns the yearly salary (i.e. twelve times the monthly
salary).
Write a test program that prompts the user to enter the first and last
name of an employee as well as their monthly salary. The program will then
output the yearly salary of the employee, give them a 10 percent raise, and
output the yearly salary again.
Transcribed Image Text:Create a class called Employee that includes three data members: a first name (type string), a last name (type string), and monthly salary (ty.pe int). The class will have a constructor that initializes the three data members. Include the set and get member functions for each data member. If the monthly salary is not positive, the set function will set it to 0. Also include a member function that returns the yearly salary (i.e. twelve times the monthly salary). Write a test program that prompts the user to enter the first and last name of an employee as well as their monthly salary. The program will then output the yearly salary of the employee, give them a 10 percent raise, and output the yearly salary again.
Problems Detected:
The contents of your standard output is incorrect.
Given the following was entered from the keyboard:
John Smith
10000
you displayed:
Enter:-the-employee's-first-and·last-name: Enter:-the employee's-monthly salary:-John-Smith's•yearly-salary-before-the raise•was-1200
John Smith's yearly•salary-after•the raise-is 120120000
instead of:
Enter:•the employee's-first-and·last name: Enter:•the employee's-monthly•salary:-John Smith's-yearly salary•before the raise•was 1200
John•Smith's•yearly•salary•after•the•raise•is•132000J
Failed 2 out of 4 test runs.
Failed Test Run #1 -
The contents of your standard output is incorrect.
Interactive Session
Hide Invisibles
Highlight: None
Show Highlighted Only O
Expected Result:
Your Code's Actual Result:
Enter:John- Smithe
· 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: John- Smith's yearly salary before the raise wa
John - Smith's yearly salary after the raise·is 1201200004
Transcribed Image Text:Problems Detected: The contents of your standard output is incorrect. Given the following was entered from the keyboard: John Smith 10000 you displayed: Enter:-the-employee's-first-and·last-name: Enter:-the employee's-monthly salary:-John-Smith's•yearly-salary-before-the raise•was-1200 John Smith's yearly•salary-after•the raise-is 120120000 instead of: Enter:•the employee's-first-and·last name: Enter:•the employee's-monthly•salary:-John Smith's-yearly salary•before the raise•was 1200 John•Smith's•yearly•salary•after•the•raise•is•132000J Failed 2 out of 4 test runs. Failed Test Run #1 - The contents of your standard output is incorrect. Interactive Session Hide Invisibles Highlight: None Show Highlighted Only O Expected Result: Your Code's Actual Result: Enter:John- Smithe · 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: John- Smith's yearly salary before the raise wa John - Smith's yearly salary after the raise·is 1201200004
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education