To solve this task, you can create a Python program that prompts the user for the type of employee (manager or worker), the number of vacation days used, and the number of sick days used.
First, let's create a function to calculate the number of working days in a year, excluding weekends, holidays, and sick days. As per the given information, the total number of days in a year is 365, and there are 52 weekends. We can subtract the number of weekends, holidays, and sick days from the total number of days to get the number of working days.
Next, we can create a function to calculate the total distance traveled by the employee in a year. Since employees travel from CityA to CityB and back every working day, we can multiply the number of working days by twice the distance between the cities.
Finally, we create the main function to handle user input and call the other functions. We will validate that the number of vacation days and sick days used does not exceed the entitlement of the employee for each category.
Here's an example implementation in Python:
```python
def calculate_working_days():
total_days = 365
weekends = 52 * 2 # Assuming 2 days per weekend
holidays = 0 # Assuming no additional holidays
sick_days = 0 # To be passed as an argument
return total_days - weekends - holidays - sick_days
def calculate_distance():
distance = 500
working_days = calculate_working_days() # Call the previous function
return distance * 2 * working_days
def main():
employee_type = input("Enter the type of employee (manager/worker): ")
vacation_days_used = int(input("Enter the number of vacation days used: "))
sick_days_used = int(input("Enter the number of sick days used: "))
if employee_type == "manager":
vacation_entitlement = 20
sick_entitlement = 8
elif employee_type == "worker":
vacation_entitlement = 15
sick_entitlement = 17
else:
print("Invalid employee type!")
return
if vacation_days_used > vacation_entitlement:
print("Invalid number of vacation days used!")
return
if sick_days_used > sick_entitlement:
print("Invalid number of sick days used!")
return
total_distance = calculate_distance() # Call the previous function
print("Total distance traveled in a year:", total_distance)
if __name__ == "__main__":
main()
```
In this code, we first define the function `calculate_working_days()` to calculate the total number of working days in a year. Then, we define the function `calculate_distance()` to calculate the total distance traveled based on the number of working days. The main function `main()` handles user input, validates the number of vacation and sick days used, and calls the other functions to calculate and print the total distance traveled.
Note: This code assumes that holidays and sick days are not considered in the calculation of working days. If you have additional information about holidays or if holidays are considered as working days, you can update the code accordingly.