Sichanov

report

May 9th, 2021
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. funds_needed = int(input())
  2. funds_collected = 0
  3. command = input()
  4. payments_count = 0
  5. paid_by_cash = 0
  6. total_paid_by_cash = 0
  7. paid_by_card = 0
  8. total_paid_by_card = 0
  9. is_collected = False
  10. while command != "End":
  11.     product_price = int(command)
  12.     payments_count += 1
  13.     if payments_count % 2 == 0:
  14.         if product_price >= 10:
  15.             paid_by_card += 1
  16.             total_paid_by_card += product_price
  17.             funds_collected += product_price
  18.             print('Product sold!')
  19.         else:
  20.             print('Error in transaction!')
  21.     else:
  22.         if product_price <= 100:
  23.             paid_by_cash += 1
  24.             total_paid_by_cash += product_price
  25.             funds_collected += product_price
  26.             print('Product sold!')
  27.         else:
  28.             print('Error in transaction!')
  29.     if funds_collected >= funds_needed:
  30.         is_collected = True
  31.         break
  32.     command = input()
  33. if is_collected:
  34.     average_by_cash = total_paid_by_cash / paid_by_cash
  35.     average_by_card = total_paid_by_card / paid_by_card
  36.     print(f'Average CS: {average_by_cash:.2f}')
  37.     print(f'Average CC: {average_by_card:.2f}')
  38. else:
  39.     print('Failed to collect required money for charity.')
  40.  
Advertisement
Add Comment
Please, Sign In to add comment