Guest User

CODE

a guest
Sep 18th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. charity_name <- string[3]
  2. charity_value <- float[3]
  3. charity1_sum <- 0.0
  4. charity2_sum <- 0.0
  5. charity3_sum <- 0.0
  6. charity_total <- 0.0
  7. num_customers <- 0
  8.  
  9. procedure name_entry()
  10. for num <- 0 to 2
  11. name <- ''
  12. REPEAT
  13. PRINT "Enter name of Charity # ", num + 1
  14. name <- USERINPUT
  15. UNTIL len(name) > 2
  16. charity_name[num] <- name
  17. END procedure
  18.  
  19. procedure name_display()
  20. PRINT "The list of charity names"
  21. for num <- 0 to 2
  22. PRINT charity_name[num], "is charity #", num + 1
  23. END procedure
  24.  
  25. procedure printer(x)
  26. x <- x - 1
  27. print "The charity named: ", charity_name[x], "has received a grand total of Rs", charity_value[x]
  28. END procedure
  29.  
  30. CALL name_entry()
  31. print "Enter the number of customers : "
  32. num_customers <- USERINPUT as integer
  33. CALL name_display()
  34.  
  35. for num <- 1 to num_customers
  36. choice <- ''
  37. bill_value <- 0.0
  38. REPEAT
  39. 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'"
  40. choice <- USERINPUT as string
  41. CASE choice OF
  42. '0' : CALL name_display
  43. '-1' : PRINT charity_total
  44. ENDCASE
  45. UNTIL choice = '1' or choice = '2' or choice = '3'
  46. REPEAT
  47. PRINT "Please enter value of customer's bill."
  48. bill_value <- USERINPPUT as float
  49. UNTIL bill_value > 1
  50. donation_value <- bill_value / 100
  51. CASE choice OF
  52. '1' : charity1_sum <- charity1_sum + donation_value
  53. '2' : charity2_sum <- charity2_sum + donation_value
  54. '3' : charity3_sum <- charity3_sum + donation_value
  55. ENDCASE
  56. charity_total <- charity1_sum + charity2_sum + charity3_sum
  57. PRINT "Rs.", donation_value, "have been donated to the charity named:", charity_name[int(choice)-1]
  58.  
  59. charity_value <- [charity1_sum, charity2_sum, charity3_sum]
  60.  
  61. IF charity1_sum > charity2_sum AND charity2_sum > charity3_sum THEN
  62. CALL printer(1)
  63. IF charity2_sum > charity3_sum THEN
  64. CALL printer(2)
  65. CALL printer(3)
  66. ELSE
  67. CALL printer(3)
  68. CALL printer(2)
  69. ENDIF
  70. ENDIF
  71.  
  72. IF charity2_sum > charity1_sum AND charity2_sum > charity3_sum THEN
  73. CALL printer(2)
  74. IF charity1_sum > charity3_sum THEN
  75. CALL printer(1)
  76. CALL printer(3)
  77. ELSE
  78. CALL printer(3)
  79. CALL printer(1)
  80. ENDIF
  81. ENDIF
  82.  
  83. IF charity3_sum > charity2_sum AND charity3_sum > charity1_sum THEN
  84. CALL printer(3)
  85. IF charity1_sum > charity2_sum THEN
  86. CALL printer(1)
  87. CALL printer(2)
  88. ELSE
  89. CALL printer(2)
  90. CALL printer(1)
  91. ENDIF
  92. ENDIF
Add Comment
Please, Sign In to add comment