Answer to Question #246821 in Python for Raj

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?
1
Expert's answer
2021-10-05T06:47:00-0400
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);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS