I just started learning about classes and am trying to build a calculator that tells people how much they need to tip the waiter as a small project but instead of entering myself the information i want that a user will do it himself so it will suit hes needs. now i think i built it right, the computer accepts the inputs but when i try to call the return_answer() function i get an error that says: AttributeError: tip_calculator object has no attribute 'return_answer' can someone please explain to me what i am doing wrong and how to fix it? thanks in advance :)
class tip_calculator:
def __init__(self,bill,amount_of_diners,precent):
self.bill = bill
self.amount_of_diners = amount_of_diners
self.precent = precent
def return_answer(self):
print("The amount you need to pay is: ", precent * bill / amount_of_diners ** bill * 1000)
calc = tip_calculator(int(input("What was the bill?: ")),
int(input("With how many people did you eat?: ")),
int(input("what '%' do you want to give the waiter?: ")))
calc.return_answer()