Advertisement
anton_d

02.report_system-01

Feb 4th, 2022
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. goal = int(input())
  2.  
  3. product_num = -1
  4. sum_collect = 0
  5. cash_transactions = 0
  6. card_transactions = 0
  7. cash_collect = 0
  8. card_collect = 0
  9.  
  10. while goal > sum_collect:
  11.     command = input()
  12.     product_num += 1
  13.     if command.isnumeric():
  14.         command = int(command)
  15.     else:
  16.         print('Failed to collect required money for charity.')
  17.         break
  18.     if command <= 100 and product_num % 2 == 0:
  19.         sum_collect += command
  20.         cash_collect += command
  21.         print('Product sold!')
  22.         cash_transactions += 1
  23.        
  24.     elif command >= 10 and product_num % 2 == 1:
  25.         sum_collect += command
  26.         card_collect += command
  27.         print('Product sold!')
  28.         card_transactions += 1
  29.        
  30.     else:
  31.         print('Error in transaction!')
  32.         continue
  33.  
  34. if sum_collect >= goal:
  35.     print(f'Average CS: {cash_collect / cash_transactions:.2f}')
  36.     print(f'Average CC: {card_collect / card_transactions:.2f}')
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement