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

1 answer

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.
Similar Questions
    1. answers icon 1 answer
  1. Thinking Question: [3 marks]Diagrams, calculations, analyzing a diagram, explaining what numbers mean Writing a question in the
    1. answers icon 1 answer
  2. Thinking Question: [3 marks]Diagrams, calculations, analyzing a diagram, explaining what numbers mean Writing a question in the
    1. answers icon 1 answer
    1. answers icon 1 answer
more similar questions