Support Forums

Full Version: please check if my program is correct
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Write a class named Employee that holds the following data about an employee in attributes:
name, ID number, department, and job title.
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 Engineer

This is what I did please correct me on any errors that I have made

class Employee():

def __init__(self,name,id_number,Department,jobTitle):
self.id_number=id_number
self.name=name
self.Department=Department
self.jobTitle=jobTitle
def get_id_number(self):
return self.id_number
def get_name(self):
return self.name
def get_Department(self):
return self.Department
def get_jobTitle(self):
return self.jobTitle

def main():

#create the employee object
employ1=Employee('Susan Meyer ','47899 ', 'Accounting ','Vice president')
name1=employ1.get_name()
idnum1=employ1.get_id_number()
dpt1=employ1.get_Department()
jobtitle1=employ1.get_jobTitle()

employ2=Employee('Mark Jones ','39119', 'IT ','Programmer')
name2=employ2.get_name()
idnum2=employ2.get_id_number()
dpt2=employ2.get_Department()
jobtitle2=employ2.get_jobTitle()

employ3=Employee('Joy Rogers ','81774', 'Manufacturing','Engineer')
name3=employ3.get_name()
idnum3=employ3.get_id_number()
dpt3=employ3.get_Department()
jobtitle3=employ3.get_jobTitle()

print('Name ID Number Department Job Title')
print('____________________________________________________________')
print(name1,idnum1,dpt1,jobtitle1,sep=' ')
print(name2,idnum2,dpt2,jobtitle2,sep=' ')
print(name3,idnum3,dpt3,jobtitle3,sep=' ')

main()
Why is it that you don;t just try it out and see for yourself?
(12-09-2013, 06:29 PM)mac macman Wrote: [ -> ]Why is it that you don;t just try it out and see for yourself?

I just want to see if somebody else has got a different approach to do it!!