Question 4 (Marks: 15)

Answer all questions within the context of the Sports Administration application.
Q.4.1 Write the pseudocode for an application that will pass the number of games a
player has played to a module which will calculate the net salary of a player.
A player earns R70 000 per game and as the players fall within a higher tax bracket,
they automatically pay 25% tax on their earnings. The net salary will be passed
back to the mainline logic of the application which will display the net salary of a
player.
(13)
Q.4.2 Within the context of the Sports Administration application, describe one example
of a situation where overloaded methods could be used

Q.4.1 Pseudocode:

1. Start the program.
2. Initialize the variable "gamesPlayed" to 0.
3. Prompt the user to enter the number of games played by the player and store it in the variable "gamesPlayed".
4. Call the module "calculateNetSalary" passing the variable "gamesPlayed" as a parameter.
5. The module "calculateNetSalary":
a. Initialize the variable "salaryPerGame" to 70000.
b. Calculate the total salary earned by multiplying "gamesPlayed" with "salaryPerGame" and store it in the variable "totalSalary".
c. Calculate the tax amount by multiplying "totalSalary" with 0.25 and store it in the variable "taxAmount".
d. Calculate the net salary by subtracting "taxAmount" from "totalSalary" and store it in the variable "netSalary".
e. Return the value of "netSalary".
6. Display the value of "netSalary" obtained from the module "calculateNetSalary".
7. End the program.

Q.4.2 One example of a situation where overloaded methods could be used in the Sports Administration application is when calculating the total score of a player.

Example:
1. Create an overloaded method called "calculateTotalScore".
2. Method 1: calculateTotalScore takes two parameters - "goalsScored" and "assists". This method calculates the total score by summing the values of "goalsScored" and "assists" and returns the result.
3. Method 2: calculateTotalScore takes three parameters - "goalsScored", "assists", and "penaltiesScored". This method calculates the total score by summing the values of "goalsScored", "assists", and "penaltiesScored" and returns the result.
4. Method 3: calculateTotalScore takes four parameters - "goalsScored", "assists", "penaltiesScored", and "ownGoals". This method calculates the total score by summing the values of "goalsScored", "assists", "penaltiesScored", and subtracting the value of "ownGoals", and returns the result.

These overloaded methods allow the Sports Administration application to calculate the total score of a player based on different scoring criteria. The appropriate method can be called based on the available parameters in a specific situation.

Q.4.1 Pseudocode for calculating the net salary of a player given the number of games played:

```
MODULE calculate_net_salary(number_of_games)
DECLARE gross_earnings, tax, net_salary AS NUMERIC
SET gross_earnings = number_of_games * 70000
SET tax = gross_earnings * 0.25
SET net_salary = gross_earnings - tax
RETURN net_salary
END MODULE

MAINLINE
DECLARE number_of_games AS INTEGER
DECLARE net_salary AS NUMERIC
INPUT number_of_games
SET net_salary = calculate_net_salary(number_of_games)
OUTPUT "The net salary of the player is: " + net_salary
END MAINLINE
```

Q.4.2 One example of a situation where overloaded methods could be used in the Sports Administration application could be to handle different types of achievements or performances by a player. For example, if the application needs to track and calculate bonuses or rewards for players based on their achievements, there could be overloaded methods for calculating different types of bonuses. Each overloaded method could take different parameters depending on the specific type of achievement, such as goals scored, assists made, or successful passes. This would allow the application to accurately calculate and assign appropriate bonuses based on the specific performance metrics.