Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- charity_name <- string[3]
- charity_value <- float[3]
- charity1_sum <- 0.0
- charity2_sum <- 0.0
- charity3_sum <- 0.0
- charity_total <- 0.0
- num_customers <- 0
- procedure name_entry()
- for num <- 0 to 2
- name <- ''
- REPEAT
- PRINT "Enter name of Charity # ", num + 1
- name <- USERINPUT
- UNTIL len(name) > 2
- charity_name[num] <- name
- END procedure
- procedure name_display()
- PRINT "The list of charity names"
- for num <- 0 to 2
- PRINT charity_name[num], "is charity #", num + 1
- END procedure
- procedure printer(x)
- x <- x - 1
- print "The charity named: ", charity_name[x], "has received a grand total of Rs", charity_value[x]
- END procedure
- CALL name_entry()
- print "Enter the number of customers : "
- num_customers <- USERINPUT as integer
- CALL name_display()
- for num <- 1 to num_customers
- choice <- ''
- bill_value <- 0.0
- REPEAT
- 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 <- USERINPUT as string
- CASE choice OF
- '0' : CALL name_display
- '-1' : PRINT charity_total
- ENDCASE
- UNTIL choice = '1' or choice = '2' or choice = '3'
- REPEAT
- PRINT "Please enter value of customer's bill."
- bill_value <- USERINPPUT as float
- UNTIL bill_value > 1
- donation_value <- bill_value / 100
- CASE choice OF
- '1' : charity1_sum <- charity1_sum + donation_value
- '2' : charity2_sum <- charity2_sum + donation_value
- '3' : charity3_sum <- charity3_sum + donation_value
- ENDCASE
- charity_total <- charity1_sum + charity2_sum + charity3_sum
- PRINT "Rs.", 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 charity2_sum > charity3_sum THEN
- CALL printer(1)
- IF charity2_sum > charity3_sum THEN
- CALL printer(2)
- CALL printer(3)
- ELSE
- CALL printer(3)
- CALL printer(2)
- ENDIF
- ENDIF
- IF charity2_sum > charity1_sum AND charity2_sum > charity3_sum THEN
- CALL printer(2)
- IF charity1_sum > charity3_sum THEN
- CALL printer(1)
- CALL printer(3)
- ELSE
- CALL printer(3)
- CALL printer(1)
- ENDIF
- ENDIF
- IF charity3_sum > charity2_sum AND charity3_sum > charity1_sum THEN
- CALL printer(3)
- IF charity1_sum > charity2_sum THEN
- CALL printer(1)
- CALL printer(2)
- ELSE
- CALL printer(2)
- CALL printer(1)
- ENDIF
- ENDIF
Add Comment
Please, Sign In to add comment