Looking for advice /review on my code to see if I am missing any steps from the task, missing any code or made an error, and if so what? Task found below along with my written code. (Python) #Write Here class Wages: #Declare Methods def __init__(self, name, hours, wages): self.name = name self.hours = hours self.wages = wages #Determine Name def getName(self): self.name = str(input("Enter employee's name: ")) return self.name #Validate Weekly Hours def getHours(self): while True: try: self.hours = int(input("Enter number of hours worked: ")) if self.hours <= 0: print("Value must be a number greater than 0!") continue except EOFError: continue else: return self.hours #Validte Hourly Wage def getWage(self): while True: try: self.wages = int(input("Enter your hourly wage: ")) if self.wages <= 0: print("Value must be a number greater than 0!") continue except EOFError: continue else: return self.wages #Determine Weekly Pay def payForWeek(self): pay = self.getWage() * self.getHours() if self.getHours() > 40: overtime = 40 - self.getHours() pay += 0.5 * overtime return pay return pay cont = 'Y' while cont == 'Y': weekPay = Wage() print("This Program will create a class that stores an employees name and calculates weekly pay.") print("You entered that " + getName() + " worked " + getHours() + " hour(s) this week.") print("You entered that " + getName() + " earns $" + getWage() + " per hour.") print("Pay for " + getName() + " is $" + payForWeek()) print("Do you want to run the program again? ('Y' for yes, anything else to quit)") cont = input()
Looking for advice /review on my code to see if I am missing any steps from the task, missing any code or made an error, and if so what?
Task found below along with my written code. (Python)
#Write Here
class Wages:
#Declare Methods
def __init__(self, name, hours, wages):
self.name = name
self.hours = hours
self.wages = wages
#Determine Name
def getName(self):
self.name = str(input("Enter employee's name: "))
return self.name
#Validate Weekly Hours
def getHours(self):
while True:
try:
self.hours = int(input("Enter number of hours worked: "))
if self.hours <= 0:
print("Value must be a number greater than 0!")
continue
except EOFError:
continue
else:
return self.hours
#Validte Hourly Wage
def getWage(self):
while True:
try:
self.wages = int(input("Enter your hourly wage: "))
if self.wages <= 0:
print("Value must be a number greater than 0!")
continue
except EOFError:
continue
else:
return self.wages
#Determine Weekly Pay
def payForWeek(self):
pay = self.getWage() * self.getHours()
if self.getHours() > 40:
overtime = 40 - self.getHours()
pay += 0.5 * overtime
return pay
return pay
cont = 'Y'
while cont == 'Y':
weekPay = Wage()
print("This Program will create a class that stores an employees name and calculates weekly pay.")
print("You entered that " + getName() + " worked " + getHours() + " hour(s) this week.")
print("You entered that " + getName() + " earns $" + getWage() + " per hour.")
print("Pay for " + getName() + " is $" + payForWeek())
print("Do you want to run the program again? ('Y' for yes, anything else to quit)")
cont = input()
Step by step
Solved in 2 steps with 1 images