Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

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 (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.
expand button
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 (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.
### Debugging Output Discrepancy

#### Problems Detected:
- The contents of the standard output are incorrect.

#### Input and Output Details:

**Given the following was entered from the keyboard:**
- `John Smith`
- `10000`

**Displayed Output (Incorrect):**
- Instructions: `Enter the employee's first and last name: Enter the employee's monthly salary: John Smith's yearly salary before the raise was 1200`
- Yearly Salary Calculation Error: `John Smith's yearly salary after the raise is 120120000`

**Expected Output:**
- Instructions: `Enter the employee's first and last name: Enter the employee's monthly salary: John Smith's yearly salary before the raise was 1200`
- Correct Yearly Salary: `John Smith's yearly salary after the raise is 132000`

#### Test Run Analysis:

**Failed Test Run #1:**
- The standard output was incorrect.

**Session Overview:**
- Mode: Interactive Session - W
- Invoking the "Hide Invisibles" feature to aid comprehension.

**Expected Result:**
```
Enter: John Smith
The employee's first and last name: Enter: 10000
The employee's monthly salary: John Smith's yearly salary before the raise was 1200
John Smith's yearly salary after the raise is 132000
```

**Actual Result:**
```
Enter: John Smith
The employee's first and last name: Enter: 10000
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
```

### Summary:
This test highlights a critical numerical computation error in calculating the yearly salary after a raise. The expected calculation should result in 132000, but the actual output erroneously reported 120120000. Reviewing and correcting the logic or formula used in the salary computation is advised.
expand button
Transcribed Image Text:### Debugging Output Discrepancy #### Problems Detected: - The contents of the standard output are incorrect. #### Input and Output Details: **Given the following was entered from the keyboard:** - `John Smith` - `10000` **Displayed Output (Incorrect):** - Instructions: `Enter the employee's first and last name: Enter the employee's monthly salary: John Smith's yearly salary before the raise was 1200` - Yearly Salary Calculation Error: `John Smith's yearly salary after the raise is 120120000` **Expected Output:** - Instructions: `Enter the employee's first and last name: Enter the employee's monthly salary: John Smith's yearly salary before the raise was 1200` - Correct Yearly Salary: `John Smith's yearly salary after the raise is 132000` #### Test Run Analysis: **Failed Test Run #1:** - The standard output was incorrect. **Session Overview:** - Mode: Interactive Session - W - Invoking the "Hide Invisibles" feature to aid comprehension. **Expected Result:** ``` Enter: John Smith The employee's first and last name: Enter: 10000 The employee's monthly salary: John Smith's yearly salary before the raise was 1200 John Smith's yearly salary after the raise is 132000 ``` **Actual Result:** ``` Enter: John Smith The employee's first and last name: Enter: 10000 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 ``` ### Summary: This test highlights a critical numerical computation error in calculating the yearly salary after a raise. The expected calculation should result in 132000, but the actual output erroneously reported 120120000. Reviewing and correcting the logic or formula used in the salary computation is advised.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education