import re def validate_phone_number(phone_number): # Phone number must be 10 digits. return bool(re.match(r'^\d{10}$', phone_number)) def validate_name(name): # Name must start with an uppercase letter. return bool(re.match(r'^[A-Z][a-zA-Z\s]+$', name)) def validate_email(email): # Email format must be abc@abc.com. return bool(re.match(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$', email)) def validate_date(date): # Date format must be DD-MM-YYYY. return bool(re.match(r'^(0[1-9]|[1-2][0-9]|3[0-1])-(0[1-9]|1[0-2])-\d{4}$', date)) def output_fn(): phone_number = input("Enter a 10-digit phone number: ") if validate_phone_number(phone_number): print("Valid phone number.") else: print("Invalid phone number.") name = input("Enter a name: ") if validate_name(name): print("Valid name.") else: print("Invalid name.") email = input("Enter an email address: ") if validate_email(email): print("Valid email address.") else: print("Invalid email address.") date = input("Enter a date (DD-MM-YYYY): ") if validate_date(date): print("Valid date.") else: print("Invalid date.") output_fn() ######################################################################################### class RestaurantCheck: def __init__(self, check_number, sales_tax_percent, subtotal, table_number, server_name): self.check_number = check_number self.sales_tax_percent = sales_tax_percent self.subtotal = subtotal self.table_number = table_number self.server_name = server_name def calculate_total(self): sales_tax_amount = self.subtotal * (self.sales_tax_percent / 100) total = self.subtotal + sales_tax_amount return total def print_check(self): total = self.calculate_total() filename = f"check{self.check_number}.txt" with open(filename, 'w') as file: file.write(f"Check Number: {self.check_number}\n") file.write(f"Sales tax: {self.sales_tax_percent:.1f}%\n") file.write(f"Subtotal: ${self.subtotal:.2f}\n") file.write(f"Total: ${total:.2f}\n") file.write(f"Table Number: {self.table_number}\n") file.write(f"Server: {self.server_name}\n") def oupput_fn(): check_number = int(input("Enter the check number: ")) sales_tax_percent = float(input("Enter the sales tax percentage: ")) subtotal = float(input("Enter the subtotal: ")) table_number = int(input("Enter the table number: ")) server_name = input("Enter the server's name: ") check = RestaurantCheck(check_number, sales_tax_percent, subtotal, table_number, server_name) check.print_check() oupput_fn()