fork download
  1. def calculate_excise_tax(price, tax_rate):
  2. return price * (tax_rate / 100)
  3.  
  4. def main():
  5. while True: # ใช้ Loop Statement เพื่อให้โปรแกรมทำงานซ้ำได้
  6. try:
  7. price = float(input("Enter product price: "))
  8. tax_rate = float(input("Enter excise tax rate (%): "))
  9.  
  10. tax = calculate_excise_tax(price, tax_rate)
  11. total_price = price + tax
  12.  
  13. print(f"Excise Tax: {tax:.2f}")
  14. print(f"Total Price (including tax): {total_price:.2f}")
  15.  
  16. repeat = input("Do you want to calculate again? (yes/no): ").strip().lower()
  17. if repeat != 'yes':
  18. print("Exiting program...")
  19. break
  20. except ValueError:
  21. print("Invalid input! Please enter numeric values.")# your code goes here
Success #stdin #stdout 0.13s 14124KB
stdin
Standard input is empty
stdout
Standard output is empty