Answered! On Microsoft VIsual Studio C++ need it in a C++ code that works also use the way that starts with hello world…

On Microsoft VIsual Studio C++

need it in a C++ code that works also use the way that starts with hello world

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.

Employee firstName: String lastName string gender char dependents int annual Sala double +Employee() +Employee(in first string, in last string, in gen char, in dep int, in salary double) calculate Pa double +display Employee() void get FirstName string +set FirstName (in first string) +get LastName string +setLastName (in last string) +get Gender char +set Gender in gen char) getDependents nt +setDependents (in dep int) +getAnnual Salary() double setAnnual Salary( n salary double

Listen

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!

Listen

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”

Format the currency using the following formatting services:

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.

Listen

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.

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

Expert Answer

#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;

class Employee
{
//variables
private:
string firstName;
string lastName;
char gender;
int dependents;
double annualSalary;

public:

Employee() //default constructor
{
firstName = “not given”;
lastName = “not given”;
gender = ‘U’ ;
dependents = 0;
annualSalary = 20000;
}
Employee(string firstName,string lastName,char gender,int dependents,double annualSalary)//parameterized constructor
{
this->firstName = firstName;
this->lastName = lastName;
this->gender = gender;
this->dependents = dependents;
this->annualSalary = annualSalary;
}
//set and get methods
void setFirstName(string firstName)
{
this->firstName = firstName;
}
void setLastName(string lastName)
{
this->lastName = lastName;
}
void setGender(char gender)
{
this->gender = gender;
}
void setDependents(int dependents)
{
this->dependents = dependents;
}
void setAnnualSalary(double annualSalary)
{
this->annualSalary = annualSalary;
}

string getFirstName()
{

return firstName;
}
string getLastName()
{

return lastName;
}
char getGender()
{
return gender;
}
int getDependents()
{
return dependents;
}
double getAnnualSalary()
{
return annualSalary;
}

double calculatePay() //calculate weekly pay
{
return annualSalary/52;
}
void displayEmployee() // display employee information
{
cout<<“n____________________________________________”;
cout<<“nName :ttt”<<firstName<<” “<<lastName;
cout<<“nGender :ttt”<<gender;
cout<<“nDependents :ttt”<<dependents;
cout<<“nAnnual Salary :ttt”<<annualSalary;
cout<<“nWeekly Salary :ttt”<<calculatePay();
cout<<“n____________________________________________”;
}

};

int main()
{
string firstname,lastname;
int dependents;
double annualSalary;
char gender;

Employee emp1;

cout<<setprecision(2)<<showpoint<<fixed; //set formatting

cout<<“nPlease enter your first name : “;
cin>>firstname;
emp1.setFirstName(firstname);

cout<<“nPlease enter your last name : “;
cin>>lastname;
emp1.setLastName(lastname);

cout<<“nPlease enter your gender : “;
cin>>gender;
emp1.setGender(gender);

cout<<“nPlease enter your dependents : “;
cin>>dependents;
emp1.setDependents(dependents);

cout<<“nPlease enter your annual salary : “;
cin>>annualSalary;
emp1.setAnnualSalary(annualSalary);

emp1.displayEmployee();

Employee emp2(“Mary”,”Noia”,’F’,2,150000);
emp2.displayEmployee();

return 0;
}

Output:

Please enter your first name : Nana
Please enter your last name : Liu
Please enter your gender : F
Please enter your dependents : 2
Please enter your annual salary : 60000 
____________________________________________
Name :                          Nana Liu
Gender :                        F
Dependents :                    2
Annual Salary :                 60000.00
Weekly Salary :                 1153.85
____________________________________________
____________________________________________
Name :                  Mary Noia
Gender :                        F
Dependents :                    2
Annual Salary :                 150000.00
Weekly Salary :                 2884.62
____________________________________________
Still stressed from student homework?
Get quality assistance from academic writers!