Advertisement
horozov86

02. Report System

Dec 15th, 2022
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. expected_sum = int(input())
  2.  
  3. counter_sum_cash = 0
  4. counter_sum_cards = 0
  5. sum_cash = 0
  6. sum_cards = 0
  7. collected_money = 0
  8. count_transactions = 0
  9. input_line = input()
  10. while collected_money < expected_sum:
  11.     if input_line == "End":
  12.         break
  13.  
  14.     input_line = int(input_line)
  15.     count_transactions += 1
  16.  
  17.     if count_transactions % 2 != 0:
  18.         if input_line <= 100:
  19.             print(f"Product sold!")
  20.             counter_sum_cash += 1
  21.             sum_cash += input_line
  22.  
  23.         elif input_line > 100:
  24.             print(f"Error in transaction!")
  25.  
  26.     elif count_transactions % 2 == 0:
  27.         if input_line < 10:
  28.             print(f"Error in transaction!")
  29.         else:
  30.             print(f"Product sold!")
  31.             counter_sum_cards += 1
  32.             sum_cards += input_line
  33.  
  34.     collected_money = sum_cash + sum_cards
  35.  
  36.     if collected_money >= expected_sum:
  37.         break
  38.  
  39.     input_line = input()
  40.  
  41. if input_line == "End":
  42.     print(f"Failed to collect required money for charity.")
  43.  
  44. if collected_money >= expected_sum:
  45.     average_sum_cash = sum_cash / counter_sum_cash
  46.     average_sum_cards = sum_cards / counter_sum_cards
  47.     print(f"Average CS: {average_sum_cash:.2f}")
  48.     print(f"Average CC: {average_sum_cards:.2f}")
  49.  
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement