Professional Documents
Culture Documents
Candidate Number:
Territory: Guyana
1
Algorithm
Definition of Problem:
To develop an algorithm to calculate the commission earned by sales staff members based on
their total sales for October 2024. The algorithm should find the staff member with the highest
commission and display their name, total sales, and commission, as well as the number of staff
members without commission.
Proposed Solution:
2. Create a dictionary to store each staff member's total sales and commission
3. Create a variable to store the maximum commission earned and initialize it to zero
4. Loop through the Sales Staff Members list and ask the user for the total sales for each staff
member
6. Store the total sales and commission earned in the Sales Staff Members dictionary
7. If the commission earned is greater than the maximum commission earned, update the
maximum commission earned and the name of the staff member who earned it
8. Count the number of staff members with no commission earned, and store this in a variable
9. Loop through the Sales Staff Members dictionary and increment the counter if the commission
earned is zero
10. Display the name, total sales, and commission earned of the staff member with the maximum
commission
11. Display the total number of staff members who earned no commission
2
Algorithm:
Sandiya Wheeler, Linda Davis, Rebecca Perry, Laura Lee, Anna Blake, Nancy Walker, Anita
Blue, Justin Mike, Patrick Ark, Gary Switch, Steve Bling, Adam Berry, Ray Margon, Devina
Black, Rick Richards, Sonia Clark
2. Let Sales Staff Data be an empty dictionary to store each staff member's total sales and
commission
a. Prompt the user to enter their total sales for October 2024
c. Store their total sales and commission earned in the Sales Staff Data dictionary
d. If their commission earned is greater than Max Commission, update Max Commission and the
name of the staff member who earned it
7. Display the name, total sales, and commission earned of the staff member with the maximum
commission
3
Testing and Validation:
The algorithm were by inputting the sales data for each staff member and checking if the
calculated commission is correct. We can also verify that the staff member with the highest
commission is correctly identified and that the number of staff members with no commission is
accurate.
The proposed solution has a time complexity of O (n), which is linear, as it loops through each
staff member in the Sales Staff list and the Sales Staff Data dictionary. This solution is efficient
for processing and analyzing the sales data of a small number of staff members. If the number of
staff members or the amount of data was significantly larger, more efficient algorithms such as
sort and search could be used to optimize the solution. However, for the given problem
statement, the proposed solution is simple and efficient.
4
Trace Table
To create a trace table, we need to calculate the commission for each staff member based on their
total sales. Using the provided total sales for each staff member ($8,175.0) and a commission
rate of 3%, we can calculate the commission as shown below:
The commission for each staff member is $245.25. Since all staff members have made sales,
there are no staff members without commission. The highest commission earned is $245.25 for
each staff member.
5
Program Implementation
6
Print ("Sales staff member with the highest commission earned :")
Print ("Name:” Sorted Sales Data [0] [0])
Print ("Total Sales:” Sorted Sales Data [0] [1] ["Total Sales"])
Print ("Commission:” Sorted Sales Data [0] [1] ["Commission"])
# Count the number of staff members with zero commission earned
No Commission Count = 0
For staff in Sales Staff Data:
If Sales Staff Data [staff] ["Commission"] == 0.0:
No Commission Count += 1
# Display the total number of staff members who earned no commission
Print ("Number of staff members who earned no commission:” no Commission Count)
```
Note: This program assumes that the total sales data is provided by the user at runtime using the
`input () ` function.
7
THE END