Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- charity_name, charity_value = [3], [3]
- charity1_sum, charity2_sum, charity3_sum, charity_total = 0.0, 0.0, 0.0, 0.0
- # Function definitions | Clean |
- def name_entry():
- for num in range(3):
- name = ''
- while(len(name) < 3): # consult pre_release for length of charity name
- print("Enter name of Charity # " + str(num+1) + ".", end = (" "))
- name = input('')
- charity_name[num] = name
- def name_display(): # Prints for mapping needed for input in loop.
- print("\nThe list of charity names.")
- for count in range(len(charity_name)):
- print("\t" + charity_name[count] + " is " + "charity # " + str(count + 1) )
- print()
- def printer(x):
- x -= 1
- print("The charity named: " + charity_name[x] + "has received a grand total of Rs. " + str(charity_value[x]))
- name_entry()
- print("Enter the number of customers : ", end =" ")
- num_customers = int(input(''))
- name_display()
- for customer in range(1, num_customers + 1):
- choice = ''
- bill_value = 0
- while(not choice == '1' and not choice == '2' and not choice == '3'): # Only 1,2,3 are accepted as valid inputs
- print("Please choose a charity by entering in its number. To view current total for all charities enter: '-1'.\nTo see the mappings of numbers to charity names enter: '0'")
- choice = input('')
- if choice == '-1':
- print(charity_total)
- elif choice == '0':
- name_display()
- while(bill_value < 1): # You can't have a bill value less than 1 else why bother he aint a customer
- print("Please enter value of customer's bill.", end = ' ')
- bill_value = float(input(''))
- donation_value = bill_value / 100
- if choice == '1':
- charity1_sum = charity1_sum + donation_value
- elif choice == '2':
- charity2_sum = charity2_sum + donation_value
- else:
- charity3_sum = charity3_sum + donation_value
- charity_total = charity1_sum + charity2_sum + charity3_sum
- print("Rs. " + str(donation_value) + " have been donated to the Charity named: " + charity_name[int(choice)-1])
- charity_value = [charity1_sum, charity2_sum, charity3_sum]
- if charity1_sum > charity2_sum and charity1_sum > charity3_sum:
- printer(1)
- if charity2_sum > charity3_sum:
- printer(2)
- printer(3)
- else:
- printer(3)
- printer(2)
- elif charity2_sum > charity1_sum and charity2_sum > charity3_sum:
- printer(2)
- if charity1_sum > charity3_sum:
- printer(1)
- printer(3)
- else:
- printer(3)
- printer(1)
- else:
- printer(3)
- if charity2_sum > charity1_sum:
- printer(2)
- printer(1)
- else:
- printer(1)
- printer(2)
- print("The grand total donated to the various charities is Rs. " + str(charity_total))
Add Comment
Please, Sign In to add comment