138k views
5 votes
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.

User Gonzojive
by
6.6k points

2 Answers

2 votes

Answer:

The previous andwers needed a few tweaks to be correct.

Step-by-step explanation:

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 = 'Mark Jones'

emp_obj2.Id_num = '39119'

emp_obj2.emp_dept = 'IT'

emp_obj2.emp_job_title = 'Programmer'

#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 = 'Engineer'

#Display the details of each employee objects.

print('Name:', emp_obj1.emp_name)

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

print('Department:', emp_obj1.emp_dept)

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

print()

print('Name:', emp_obj2.emp_name)

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

print('Department:', emp_obj2.emp_dept)

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

print()

print('Name:', emp_obj3.emp_name)

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

print('Department:', emp_obj3.emp_dept)

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

User Nixkuroi
by
7.1k points
1 vote

Answer:

Check the explanation

Step-by-step 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.

Write a class named Employee that holds the following data about an employee in attributes-example-1
User Marijn Kneppers
by
7.3k points