One way to calculate the education (edu) of a person could be to use a formula that takes into account their highest level of education completed and the number of years they spent in education. Here's a possible implementation in Swift:
main.swift342 chars19 lines
This function takes two parameters: the level of education completed (as a String) and the number of years spent in education (as an Int). It then calculates the edu value based on the level of education completed, using the following conversion rates:
For example, if someone completed a Bachelor's Degree and spent 4 years in education, their edu value would be 16 + 4 + 12 = 32.
gistlibby LogSnag