Encrypting your link and protect the link from viruses, malware, thief, etc! Made your link safe to visit.

Write a class named Employee that has the following properties. • Name: The Name property holds the employee's name. • IdNumber: The IdNumber property holds the employee's ID number. • Department: The Department property holds the name of the department in which the employee works. • Position: The Position property holds the employee's job title. The class should have the following overloaded constructors: • A constructor that accepts the following values as arguments and assigns them to the appropriate properties: employee's Name, IdNumber, Departmentand Position. • A constructor that accepts the following values as arguments and assigns them to the appropriate properties: employee's Name and IdNumber. The Departmentand Position properties should be assigned an empty string. • A parameter less constructor that assigns empty string to Name, Department and Position properties, and 0 to IdNumber.

 

Question:


Write a class named Employee that has the following properties. • Name: The Name property holds the employee's name. • IdNumber: The IdNumber property holds the employee's ID number. • Department: The Department property holds the name of the department in which the employee works. • Position: The Position property holds the employee's job title. The class should have the following overloaded constructors: • A constructor that accepts the following values as arguments and assigns them to the appropriate properties: employee's Name, IdNumber, Departmentand Position. • A constructor that accepts the following values as arguments and assigns them to the appropriate properties: employee's Name and IdNumber. The Departmentand Position properties should be assigned an empty string. • A parameter less constructor that assigns empty string to Name, Department and Position properties, and 0 to IdNumber.

Create three employee objects to hold the following information: Name Susan Meyers Mark Jones Joy Rogers id Number 47899 3911

Show transcribed image text


Answer:


Since it was not specified which programming language to use I have implemented the code in C++ and python.

1) C++ Implementation:

#include<bits/stdc++.h>
using namespace std;

class Employee{
private:
   char* Name;
   int ID;
   char* Dept;
   char* Position;

public:
   Employee(){
       Name=Dept=Position=(char*)"";
       ID=0;
   }
   Employee(int ID,char* Name,char* Dept,char* Position){
       this->ID=ID;
       this->Name=Name;
       this->Dept=Dept;
       this->Position=Position;
   }
   Employee(int ID,char* Name){
       this->ID=ID;
       this->Name=Name;
       Dept=(char*)"";
       Position=(char*)"";
   }
   void printAllStats(){
       cout<<"ID "<<ID<<" ";
       cout<<"Name "<<Name<<" ";
       cout<<"Department "<<Dept<<" ";
       cout<<"Position "<<Position<<"\n";

   }
};

int main(){
   Employee E1(47899,(char*)"Susan Meyers",(char*)"Accounting",(char*)"Vice President");
   Employee E2(39119,(char*)"Mark Jones",(char*)"IT",(char*)"Programmer");
   Employee E3(81774,(char*)"Joy Rogers",(char*)"Manufracturing",(char*)"Engineer");

   cout<<"Employees' Info:\n";
   cout<<"Employee1\t";
   E1.printAllStats();

   cout<<"Employee2\t";
   E2.printAllStats();

   cout<<"Employee3\t";
   E3.printAllStats();


   return 0;
}

2) Python Implementation:

class Employee:
   def __init__(self):
       self.ID=0
       self.Name=""
       self.Dept=""
       self.Position=""

   def __init__(self,ID,Name,Dept="",Position=""):
       self.ID=ID
       self.Name=Name
       self.Dept=Dept
       self.Position=Position

   def printAllStats(self):
       return " ".join(["ID",str(self.ID),"Name",self.Name,"Department",self.Dept,"Position",self.Position])

E1=Employee(47899,"Susan Meyers","Accounting","Vice President")
E2=Employee(39119,"Mark Jones","IT","Programmer");
E3=Employee(81774,"Joy Rogers","Manufracturing","Engineer")

print("Employee Info:\n")
print("Employee 1:",E1.printAllStats())
print("Employee 2:",E2.printAllStats())
print("Employee 3:",E3.printAllStats())

  • Below I am attaching python code screenshot for Indentation purpose:

- 0 X EDXChegg\simple employee class Employeepy - Sublime Text (UNREGISTERED) File Edit Selection Find View Goto Tools Projec

  • Below is the C++ implementation and Output:

E DAChego simple employee class Employee.cpp - Sublime Text (UNREGISTERED) File Edit Selection Find View Golo Tools Project P

ST

Search This Blog

Labels

Report Abuse

QUESTION 6 (a) The bar shown in Figure Q2(a) is subjected to tensile load of 150 Kn. If the stress in the middle portions is limited to 160 N/mm², determine the diameter of the middle portion. Find also the length of the middle portion if the total elongation of the bar is to be 0.25 mm. E E = 2.0 + 105N/mm². (12 marks) 150 KN 10 cm DIA 10 cm DIA 150 KN 45 cm Figure Q6(a) (b) A brass bar, having cross-section area of 900 mm², is subjected to axial forces as shown in Figure Q2(b), in which AB = 0.6 m, BC = 0.8 m, and CD = 1.0 m. Find the total elongation of the bar. E = 1.0 + 105N/mm2 . (8 marks) Page 4 of 5 B D 40 KN 70 KN 20 KN 10 KN Figure Q6(b) (TOTAL = 20 MARKS)

  Question: Show transcribed image text Answer:

Question: A 250-V, 4-pole, wave-wound d.c. series motor has 782 conductors on itsarmature. It has armature and series field resistance of 0.75 ohm. The motor takesa current of 40 A. Estimate its speed and gross torque developed if it has a flux per pole of 25 mWb Answer: Step 1 Mechanical Engineering homework question answer, step 1, image 1 Mechanical Engineering homework question answer, step 1, image 2 Step 2 Mechanical Engineering homework question answer, step 2, image 1 Step 3 Mechanical Engineering homework question answer, step 3, image 1

Question: A 250-V, 4-pole, wave-wound d.c. series motor has 782 conductors on itsarmature. It has armature and series field resistance of 0.75 ohm. The motor takesa current of 40 A. Estimate its speed and gross torque developed if it has a flux per pole of 25 mWb Answer: Step 1 Step 2 Step 3

Contributors