Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

On microsoft visual studio C++ We begin our investigation of object-oriented pro

ID: 3856459 • Letter: O

Question

On microsoft visual studio C++

We begin our investigation of object-oriented programming by creating an object-oriented program with a class called Employee. You will create two objects based on the Employee class, along with a class that contains the main method. The attributes, constructors, and methods for this class must satisfy the requirements in Steps 1 through 3. After you create the objects, you will prompt the user for information and then display it.

We will want to ensure that this first class is well-constructed and tested since we will extend this class in Labs 3 through 6.

Software Citation Requirements

This course uses open-source software, which must be cited when used for any student work. Citation requirements are on the Open Source Applications page.
Please review the installation instruction files to complete your assignment.

Deliverables

Due this week:

Capture the Console output window and paste it into a Word document.

Zip the project folder files.

Upload the zip file and screenshots (Word document that contains programming code and screenshots of program output).

Required Software

Connect to the Lab here. (Links to an external site.)Links to an external site.

Lab Steps

STEP 1: Understand the UML Class Diagram

Use the following UML diagram to build the class. The first section specifies the attributes. The second section specifies the behaviors, and the first character specifies the access modifier value, where:

"-" means that the class member is private, and

"+" means that the class member is public.

STEP 2: Code the Employee Class

Create a new project called "CIS247B_Week2Lab_YourName".

Using the provided Class Diagram from Step 1, code the Employee class in the new project (i.e., "Realize the UML Class diagrams").

The default constructor should set the attributes as follows: firstName = "not given", lastName = "not given", gender = "U" (for unknown), dependents = 0, and annualSalary = 20,000.

The multi-arg constructor should initialize all of the attributes using values passed in using its parameter list.

As shown in the Class diagram, each attribute should have a "getter" to retrieve the stored attribute value, and a "setter" that modifies the value.

The calculatePay( ) method of the Employee class should return the value of annual salary divided by 52 (return annualSalary / 52;).

The displayEmployee() method should display all the attributes of the Employee object in a well-formatted string with logical labels applied to each attribute. Don't forget to call calculatePay from within the displayEmployee method in order to display the Employee's weekly pay as well!

STEP 3: Code the Main Program

In the Main class, create code statements that perform the following operations. Be sure you follow proper commenting and programming styles (header, indentation, line spacing, etc.).

Create an Employee object using the default constructor.

Prompt for and then set the first name, last name, gender, dependents, and annual salary. (Remember that you have to convert gender, dependents, and annual salary from strings to the appropriate data type.)

Using your code from last week, display a divider that contains the string "Employee Information"

Display the Employee information.

Create a second Employee object using the multi-argument constructor, setting each of the attributes with appropriate valid values.

Using your code from last week, display a divider that contains the string "Employee Information".

Display the Employee information for the second Employee object.

STEP 4: Compile and Test

When done, compile and run your code.

Then, debug any errors until your code is error-free.

Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.

STEP 5: Screen Prints

Capture the Console output window and paste into a Word document. The following is a sample screen.

Explanation / Answer

// Example program
#include <iostream>
#include <string>
using namespace std;
class Employee
{
  
public:
string firstName;
string lastName;
char gender;
int dependents;
double annualSalary;
double weeklySalary;
string getFirstName()
{
return firstName;
}

void setFirstName(string x)
{
firstName = x;
}
string getLastName()
{
return lastName;
}

void setLastName(string x)
{
lastName = x;
}
char getGender()
{
return gender;
}

void setGender(char x)
{
gender = x;
}
int getDependents()
{
return dependents;
}

void setDependents(int x)
{
dependents = x;
}
double getAnnualSalary()
{
return annualSalary;
}

void setAnnualSalary(double x)
{
annualSalary = x;
}
double calculatePay()
{
weeklySalary=annualSalary / 52;
return annualSalary / 52;
}
void displayEmployee()
{
cout<<" Employee Information";
cout<<" Name "<<firstName+" "+lastName;

cout<<" Gender "<<gender;
cout<<" Dependents "<<dependents;
cout<<" Annual Salary "<<annualSalary;
cout<<" Weekly Salary "<<weeklySalary;

}
};
int main()
{
Employee objEmployee;
string firstName,lastName;
char gender;
int dependents;
double annualSalary;
cout<<"Please Enter Your First Name ";
cin>>firstName;
objEmployee.setFirstName(firstName);

cout<<" Please Enter Your Last Name ";
cin>>lastName;
objEmployee.setLastName(lastName);

cout<<" Please Enter Your Gender ";
cin>>gender;
objEmployee.setGender(gender);

cout<<" Please Enter Your Dependents ";
cin>>dependents;
objEmployee.setDependents(dependents);

cout<<" Please Enter Your AnnualSalary ";
cin>>annualSalary;
objEmployee.setAnnualSalary(annualSalary);

objEmployee.calculatePay();

objEmployee.displayEmployee();


}

Output:

Please Enter Your First Name Hemanth

Please Enter Your Last Name Kumar

Please Enter Your Gender M

Please Enter Your Dependents 2

Please Enter Your AnnualSalary 60000

Employee Information

Name Hemanth Kumar

Gender M

Dependents 2

Annual Salary 60000

Weekly Salary 1153.85

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote