Question #246821

an ecommerce company plans to give their customers a discount for the new year. the discount will be calculated on the basis of the bill amount is the product of the sum of all odd digits and the sum of even digits of the customer's total bill. if no odd-even digit is represented in the bill amount then 0 will be returned?

Expert's answer

def calculateDiscount(billAmount):
    bill_amount=billAmount
    sumOddDigits=0
    sumEvenDigits =0
    while(bill_amount>0):
        digit=bill_amount%10 
        if(digit%2==0):
            sumEvenDigits+=digit
        else:
            sumOddDigits+=digit
        bill_amount=bill_amount/10
    return sumOddDigits*sumEvenDigits




billAmount=0;
discount=0;
totalBill=0;
billAmount=int(input("Enter the bill amount: "));
discount=calculateDiscount(billAmount);




totalBill=discount+billAmount;
print("Discount is:",discount);
print("The total bill is:",totalBill);

LATEST TUTORIALS
APPROVED BY CLIENTS