bl00dt3ars

02. Report System

Nov 6th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. required_money = int(input())
  2. earned_money = 0
  3. product_counter = 0
  4. cs_total_money = 0
  5. cs_counter = 0
  6. cc_total_money = 0
  7. cc_counter = 0
  8.  
  9. line = input()
  10. while line != "End" and required_money >= earned_money:
  11.     product_price = int(line)
  12.     product_counter += 1
  13.     if product_counter % 2 == 0:
  14.         if product_price < 10:
  15.             print("Error in transaction!")
  16.         else:
  17.             cc_total_money += product_price
  18.             cc_counter += 1
  19.             earned_money += product_price
  20.             print("Product sold!")
  21.     else:
  22.         if product_price > 100:
  23.             print("Error in transaction!")
  24.         else:
  25.             cs_total_money += product_price
  26.             cs_counter += 1
  27.             earned_money += product_price
  28.             print("Product sold!")
  29.     if earned_money >= required_money:
  30.         break
  31.     line = input()
  32.  
  33. if earned_money >= required_money:
  34.     print(f"Average CS: {cs_total_money / cs_counter:.2f}")
  35.     print(f"Average CC: {cc_total_money / cc_counter:.2f}")
  36. else:
  37.     print(f"Failed to collect required money for charity.")
Add Comment
Please, Sign In to add comment