Write a program to create a class named employee details


Asked by wiki @ in Computers and Technology viewed by 148 People


Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. Don't include a constructor or any other methods. Once you have written the class, write a program that creates three Employee objects to hold the following data: Name ID Number Department Job Title Susan Meyers 47899 Accounting Vice President Mark Jones 39119 IT Programmer Joy Rogers 81774 Manufacturing Engineering The program should store this data in three Employee objects and then print the data for each employee.

Answered by wiki @


Answer:

Check the explanation

Explanation:

#Define the class Employee.

class Employee:

   #Declare and initialize the required member variables.

   emp_name = ''

   Id_num = ''

   emp_dept = ''

   emp_job_title = ''

#Create an object of the class Employee.

emp_obj1 = Employee()

#Assign required values to the members of the class for a

#particular object.

emp_obj1.emp_name = 'Susan Meyers'

emp_obj1.Id_num = '47899'

emp_obj1.emp_dept = 'Accounting'

emp_obj1.emp_job_title = 'Vice President'

#Create another object of the class Employee.

emp_obj2 = Employee()

#Assign required values to the members of the class for the

#current object.

emp_obj2.emp_name = 'Marke Jones'

emp_obj2.Id_num = '39119'

emp_obj2.emp_dept = 'IT'

emp_obj2.emp_job_title = 'programming'

#Create another object of the class Employee.

emp_obj3 = Employee()

#Assign required values to the members of the class for the

#current object.

emp_obj3.emp_name = 'Joy Rogers'

emp_obj3.Id_num = '81774'

emp_obj3.emp_dept = 'Manufacturing'

emp_obj3.emp_job_title = 'Engineering'

#Display the details of each employee objects.

print('Employee 1 details:')

print('Employee Name:', emp_obj1.emp_name)

print('Employee ID Number:', emp_obj1.Id_num)

print('Employee Department:', emp_obj1.emp_dept)

print('Employee Job Title:', emp_obj1.emp_job_title)

print()

print('Employee 2 details:')

print('Employee Name:', emp_obj2.emp_name)

print('Employee ID Number:', emp_obj2.Id_num)

print('Employee Department:', emp_obj2.emp_dept)

print('Employee Job Title:', emp_obj2.emp_job_title)

print()

print('Employee 3 details:')

print('Employee Name:', emp_obj3.emp_name)

print('Employee ID Number:', emp_obj3.Id_num)

print('Employee Department:', emp_obj3.emp_dept)

print('Employee Job Title:', emp_obj3.emp_job_title)

Kindly check the attached image below for the code output.

Do you know the better answer?

Similar Questions

Write a class named employee that has the following fields

Asked by wiki @ in Computers and Technology viewed by 181 persons

Use Java to write a class named Employee that has the following fields: name - The name field references a String object that holds the employee's name; idNumber - The …

Write a program to calculate area of circle in c++

Asked by wiki @ in Computers and Technology viewed by 90 persons

I want to write a C++ program to read the diameter of a circle. The program should find and display the area and circumference of the circle. Define a constant …

This is the code name for the atomic bomb program

Asked by wiki @ in History viewed by 117 persons

The "Manhattan Project" was the code name for the A) U.S. plan to invade Japan. B) German use of jet aircraft. C) Allied plan to invade Europe. D) U.S. plans …

Write a program to print 1 4 9 16 25

Asked by wiki @ in Computers and Technology viewed by 119 persons

Write a while loop that prints A. All squares less than n. For example, if n is 100, print 0 1 4 9 16 25 36 49 64 81. B. …

Which technical development allowed artists to create highly detailed paintings

Asked by wiki @ in Arts viewed by 198 persons

What technical development allowed artists to create highly detailed paintings?

Write a c++ program to calculate gpa in a semester

Asked by wiki @ in Computers and Technology viewed by 74 persons

Write a C++ program that opens and reads file question2.txt. File question1.txt has 3 students and 3 grades of each. You program should read values from file and assign values …

Write a program to split number into digits in java

Asked by wiki @ in Computers and Technology viewed by 126 persons

Write a Java program that asks the user to enter a 10-digit string as a typical U.S. telephone number, extracts the 3-digit area code, the 3-digit "exchange," and the remaining …

Write a program to find area of rectangle in java

Asked by wiki @ in Computers and Technology viewed by 102 persons

1 Write a java program which calculates the area of either a Triangle or a Rectangle. Use Scanner to take an input field to tell you if the area to …

What did the new american middle class create answers com

Asked by wiki @ in History viewed by 104 persons

What did the new American middle class create?

Write the name of the period that has digits 913

Asked by wiki @ in Mathematics viewed by 80 persons

Write the name of the period that has the digits 913.

Write the name of the period that has the digits

Asked by wiki @ in Mathematics viewed by 66 persons

Write the name of the period that has the digits 913.

Write a program that implements the following disk scheduling algorithms

Asked by wiki @ in Computers and Technology viewed by 127 persons

Write a program that implements the following disk-scheduling algorithms: (Pick three) a. FCFS b. SSTF c. SCAN d. C-SCAN e, LOOK f. C-LOOK Your program will service a disk with …

What is the name of the fccla national outreach program

Asked by wiki @ in Arts viewed by 218 persons

What is the name of the national outreach project for fccla?

Which job role involves writing programs to automate computer tasks

Asked by wiki @ in Computers and Technology viewed by 128 persons

HELPPPPPPPPPPPPPPPPPPPPPPPPPPPPWhich job role involves writing programs to automate computer tasks? technical support specialist network administrator network engineer computer programmer software developer

Which of the following programs were created during fdr's administration

Asked by wiki @ in History viewed by 160 persons

Select all that apply. Which of the following programs were created during FDR's administration? Fourteen Points Social Security Act Home Loan Bank System Washington Disarmament Conference Agricultural Adjustment Act McNary-Haugen …

Most viewed questions in Computers And Technology


A customer wants to increase the storage capacity by 25gb

Asked by wiki @ in Computers and Technology viewed by 4137 persons



Which item is not part of a college application everfi

Asked by wiki @ in Computers and Technology viewed by 983 persons


Which one of these can connect directly to the internet

Asked by wiki @ in Computers and Technology viewed by 976 persons


The following are ways to avoid having a collision except

Asked by wiki @ in Computers and Technology viewed by 961 persons



What makes a sequence of database operations a transaction

Asked by wiki @ in Computers and Technology viewed by 945 persons



Which of the following is not true about mobile health

Asked by wiki @ in Computers and Technology viewed by 760 persons



Which internet protocol version is 100.0 0.256

Asked by wiki @ in Computers and Technology viewed by 741 persons


Cloud storage refers to the storage of data on

Asked by wiki @ in Computers and Technology viewed by 570 persons