Advertisement
anton_d

02.report_system

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