Please, I want to modify the code so that the user can add the employee's name, number and specialization, and use for loob He must add more than one employee. When he finishes adding the employee’s data, he asks the user: Do you want 1-Print the data 2-Add a new employee 3-Exit class Doctor: """Represents a Doctor""" #initializer with specialization default to "general" def __init__(self, Id, name, specialization="general"): #attributes self.Id = Id self.name = name self.specialization = specialization.lower() #initializing salary to 25000, basic salary self.salary = 25000 #incrementing salary based on specialization #if specialization is pediatric, increasing salary by 10% if specialization == "pediatric": self.salary += self.salary*10/100 #if specialization is dental, increasing salary by 15% elif specialization == "dental": self.salary += self.salary*15/100 #str() function def __str__(self): return (f"Id: {self.Id} \n" f"Name: {self.name} \n" f"Specialization: {self.specialization} \n" f"Salary: AED {self.salary:.2f} \n") #creating a Doctor object with "pediatric" as specialization pediatric_doctor = Doctor(1, "Steve", "pediatric") print(pediatric_doctor) #creating a Doctor object with "dental" as specialization dental_doctor = Doctor(2, "Mark", "dental") print(dental_doctor) #### comment to me, if any doubts ####
Please, I want to modify the code so that the user can add the employee's name, number and specialization, and use for loob He must add more than one employee. When he finishes adding the employee’s data, he asks the user: Do you want 1-Print the data 2-Add a new employee 3-Exit
class Doctor:
"""Represents a Doctor"""
#initializer with specialization default to "general"
def __init__(self, Id, name, specialization="general"):
#attributes
self.Id = Id
self.name = name
self.specialization = specialization.lower()
#initializing salary to 25000, basic salary
self.salary = 25000
#incrementing salary based on specialization
#if specialization is pediatric, increasing salary by 10%
if specialization == "pediatric":
self.salary += self.salary*10/100
#if specialization is dental, increasing salary by 15%
elif specialization == "dental":
self.salary += self.salary*15/100
#str() function
def __str__(self):
return (f"Id: {self.Id} \n"
f"Name: {self.name} \n"
f"Specialization: {self.specialization} \n"
f"Salary: AED {self.salary:.2f} \n")
#creating a Doctor object with "pediatric" as specialization
pediatric_doctor = Doctor(1, "Steve", "pediatric")
print(pediatric_doctor)
#creating a Doctor object with "dental" as specialization
dental_doctor = Doctor(2, "Mark", "dental")
print(dental_doctor)
#### comment to me, if any doubts ####
Step by step
Solved in 2 steps with 4 images