Guest User

CODE_P

a guest
Sep 18th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.80 KB | None | 0 0
  1. charity_name, charity_value = [3], [3]
  2. charity1_sum, charity2_sum, charity3_sum, charity_total = 0.0, 0.0, 0.0, 0.0
  3.  
  4. # Function definitions | Clean |
  5. def name_entry():
  6.     for num in range(3):
  7.         name = ''
  8.         while(len(name) < 3): # consult pre_release for length of charity name
  9.             print("Enter name of Charity # " + str(num+1) + ".", end = (" "))
  10.             name = input('')
  11.         charity_name[num] = name
  12.  
  13. def name_display(): # Prints for mapping needed for input in loop.
  14.     print("\nThe list of charity names.")
  15.     for count in range(len(charity_name)):
  16.         print("\t" + charity_name[count]  + " is " + "charity # " + str(count + 1) )
  17.     print()
  18.  
  19. def printer(x):
  20.     x -= 1
  21.     print("The charity named: " + charity_name[x] + "has received a grand total of Rs. " + str(charity_value[x]))
  22.  
  23. name_entry()
  24. print("Enter the number of customers : ", end =" ")
  25. num_customers = int(input(''))
  26. name_display()
  27.  
  28. for customer in range(1, num_customers + 1):
  29.     choice = ''
  30.     bill_value = 0
  31.     while(not choice == '1' and not choice == '2' and not choice == '3'): # Only 1,2,3 are accepted as valid inputs
  32.         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'")
  33.         choice = input('')
  34.         if choice == '-1':
  35.             print(charity_total)
  36.         elif choice == '0':
  37.             name_display()
  38.     while(bill_value < 1): # You can't have a bill value less than 1 else why bother he aint a customer
  39.         print("Please enter value of customer's bill.", end = ' ')
  40.         bill_value = float(input(''))
  41.     donation_value = bill_value / 100
  42.     if choice == '1':
  43.         charity1_sum = charity1_sum + donation_value
  44.     elif choice == '2':
  45.         charity2_sum = charity2_sum + donation_value
  46.     else:
  47.         charity3_sum = charity3_sum + donation_value
  48.     charity_total = charity1_sum + charity2_sum + charity3_sum
  49.     print("Rs. " + str(donation_value) + " have been donated to the Charity named: " + charity_name[int(choice)-1])
  50.  
  51. charity_value = [charity1_sum, charity2_sum, charity3_sum]
  52.  
  53. if charity1_sum > charity2_sum and charity1_sum > charity3_sum:
  54.     printer(1)
  55.     if charity2_sum > charity3_sum:
  56.         printer(2)
  57.         printer(3)
  58.     else:
  59.         printer(3)
  60.         printer(2)
  61. elif charity2_sum > charity1_sum and charity2_sum > charity3_sum:
  62.     printer(2)
  63.     if charity1_sum > charity3_sum:
  64.         printer(1)
  65.         printer(3)
  66.     else:
  67.         printer(3)
  68.         printer(1)
  69. else:
  70.     printer(3)
  71.     if charity2_sum > charity1_sum:
  72.         printer(2)
  73.         printer(1)
  74.     else:
  75.         printer(1)
  76.         printer(2)
  77.  
  78. print("The grand total donated to the various charities is Rs. " + str(charity_total))
Add Comment
Please, Sign In to add comment