I need this in C++ as simple to read as possible please. I am a beginner and thi
ID: 3536448 • Letter: I
Question
I need this in C++ as simple to read as possible please. I am a beginner and this seems way beyond my ability so I will use the answer to learn what I am lost on. I appreciate the help. My last question was the same but the lab was missing some info eventhough I posted it here. it must have been cut off.
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.
_____________________________________________________________________________________
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:
Employee
-firstName : string
- lastName : string
- gender : char
- dependents : int
- annualSalary : double
+Employee()
+Employee(in first : string, in last : string, in gen : char, in dep : int, in salary : double)
+calculatePay() : double
+displayEmployee() : void
+getFirstName() : string
+setFirstName(in first : string)
+getLastName() : string
+setLastName(in last : string)
+getGender() : char
+setGender(in gen : char)
+getDependents() : int
+setDependents(in dep : int)
+getAnnualSalary() : double
+setAnnualSalary(in salary : double)
STEP 2: Code the Employee Class
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.).
<< setprecision(2)<<showpoint<<fixed<<annualSalary << " ";
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.
Screenshot of a program output that reads: Welcome to your first Object Oriented Program--Employee ClassCIS247C, Week 2 Lab Name: Prof.Nana Liu *************** Employee 1 *************** Please enter your First Name Nana Please enter your Last Name Liu Please enter your Gender Female Please enter your Dependents 2 Please enter your Annual Salary 60000 Employee Information ___________________________________________ Name: Nana Liu Gender: F Dependents: 2 Annual Salary: 60000.00 Weekly Salary 1153.85 *************** Employee 2 *************** Name: Mary Noia Gender: F Dependents: 2 Annual Salary: 150000.00 Weekly Salary: 2884.62 The end of the CIS247C Week 1 iLab. Press any key to continue...
STEP 6: Submit Deliverables
STEP 2: Code the Employee Class
Explanation / Answer
e 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. 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: %u2022 "-" means that the class member is private, and %u2022 "+" means that the class member is public. The following header files need to be included to support input/output, string processing and formatting services - #include <iostream> #include <string> #include <stdlib.h> #include <iomanip> In this class Employee, we will need to declare five data members %u2013 -firstName: string -lastName: string -gender: char -dependents int -annualSalary double In addition, we will need to declare two constructors %u2013 %u2022 Employee()//default constructor %u2022 Employee(string firstName, string lastName, char gender, int dependents, double salary) //create a parameterized constructor A series of getters and setters methods for get and set the following data members %u2013 -firstName string getFirstName(){ } void setFirstName(string name) { } -lastName string getLastName(){ } void setLastName(string name) { } -gender char getGender(){ } void setGender(char gen) { } -dependents int getDependents(){ } void setDependents(int dep) { } -annualSalary double getAnnualSalary() { } void setAnnualSalary(double salary) { } A calculatePay() method that calculates the weekly pay - double calculatePay() { } A displayEmployee() method that displays all the employee information - void displayEmployee() { } STEP 2: Code the Employee Class 1. Create a new project called "CIS247B_Week2Lab_YourName". 2. Using the provided Class Diagram from Step 1, code the Employee class in the new project (i.e., "Realize the UML Class diagrams"). 3. The default constructor should set the attributes as follows: firstName = "not given", lastName = "not given", gender = %u2018U%u2019 (for unknown), dependents = 0, and annualSalary = 20,000. Based on the given value, we just need to assign all the default values to the data members in the constructor %u2013 Employee()//default constructor { firstName = "not given"; lastName = "not given"; gender = 'U'; dependents = 0; annualSalary = 20000; } 4. The multi-arg constructor should initialize all of the attributes using values passed in using its parameter list. Employee(string firstName, string lastName, char gender, int dependents, double salary) { //use the this pointer to distinguish between the class attributes and the parameters this->firstName = firstName; this->lastName = lastName; this->gender = gender; this->dependents = dependents; this->annualSalary = salary; } 5. 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 getters simply returns the data member for outside of class access %u2013 string getFirstName() { return firstName; } The setters allows validation and reassigning values to the data member- void setFirstName(string name) { firstName = name; } 6. The calculatePay( ) method of the Employee class should return the value of annual salary divided by 52 (return annualSalary / 52;). double calculatePay(){return annualSalary/52;} 7. 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! When we display the annualSalary and weekly pay, we need to apply appropriate formatting so the dollar amount can be displayed in a neat two digit format. void displayEmployee() { cout<<"Employee Information "; cout<<"____________________________________________________________ "; cout<<"Name: " <<firstName << " " << lastName << " "; cout<<"Gender: " << gender << " "; cout<<"Dependents: " << dependents << " "; cout<<"Annual Salary: " << setprecision(2)<<showpoint<<fixed<<annualSalary << " "; cout<<"Weekly Salary: " << setprecision(2)<<showpoint<<fixed<<calculatePay(); } 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.). 1. Create an Employee object using the default constructor. 2. 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.) 3. Using your code from last week, display a divider that contains the string "Employee Information" 4. Format the currency using the following formatting services: cout<<"Annual Salary: " << setprecision(2)<<showpoint<<fixed<<annualSalary << " "; 5. Display the Employee information. 6. Create a second Employee object using the multi-argument constructor, setting each of the attributes with appropriate valid values. 7. Using your code from last week, display a divider that contains the string "Employee Information". 8. 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.Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.