Create a program that calculates and prints the amount of change to be returned to the customer after paying the bill, based on the manager's input in the system.
Sample Input:
Total Invoice amount(In Dollars): 200
Amount of Tip (In cents): 10
Total Payment received by card: 160
Service Charged on payment made by card: 4%
Total Payment received in Cash(In Dollars): 100
Output:
Change to be returned to the customer (In Dollars): 53.50
Note: If the return to the customer is negative, then it must print 'outstanding amount and need to be paid by customer:', and the amount need to be paid
# Python solution:
def calculate_change(invoice_amount, tip_amount, card_payment, service_charge, cash_payment):
# Convert service charge percentage to decimal
service_charge_decimal = service_charge / 100
# Calculate total payment made by card (including service charge)
total_card_payment = card_payment * (1 + service_charge_decimal)
# Calculate total payment (card + cash)
total_payment = total_card_payment + cash_payment
# Calculate the change to be returned
change = total_payment - (invoice_amount + tip_amount)
return change
# Get user input
invoice_amount = float(input("Total Invoice amount (In Dollars): "))
tip_amount = int(input("Amount of Tip (In cents): "))
card_payment = float(input("Total Payment received by card: "))
service_charge = float(input("Service Charged on payment made by card (%): "))
cash_payment = float(input("Total Payment received in Cash (In Dollars): "))
# Calculate and print the change
change = calculate_change(invoice_amount, tip_amount, card_payment, service_charge, cash_payment)
if change >= 0:
print(f"Change to be returned to the customer (In Dollars): {change:.2f}")
else:
print(f"Outstanding amount and need to be paid by customer: {-change:.2f}")