GeorgiLukanov87

charity deal

Mar 19th, 2022 (edited)
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. needed_income = int(input())
  2. pay_counter = 0
  3. cash_pay = 0
  4. cash_counter = 0
  5. card_pay = 0
  6. card_counter = 0
  7. total_sum = 0
  8. current_sum = 0
  9. while True:
  10.     current_sum = input()
  11.     if current_sum == "End":
  12.         print(f"Failed to collect required money for charity.")
  13.         break
  14.     current_sum = int(current_sum)
  15.     pay_counter += 1
  16.     if pay_counter % 2 != 0:
  17.  
  18.         if current_sum > 100:
  19.             print("Error in transaction!")
  20.         else:
  21.             print(f'Product sold!')
  22.             cash_pay += current_sum
  23.             cash_counter += 1
  24.     if pay_counter % 2 == 0:
  25.  
  26.         if current_sum < 10:
  27.             print('Error in transaction!')
  28.         else:
  29.             print(f'Product sold!')
  30.             card_pay += current_sum
  31.             card_counter += 1
  32.     total_sum = cash_pay + card_pay
  33.     if total_sum >= needed_income:
  34.         print(f"Average CS: {cash_pay / cash_counter:.2f}")
  35.         print(f"Average CC: {card_pay / card_counter:.2f}")
  36.         break
  37.  
Add Comment
Please, Sign In to add comment