|
Purpose of project: Allow an employee to calculate/project future 401k yearly balances based on several future promotions. With promotions come pay raises. Current challenge to overcome: Manipulate pay rates based on projected pay rate percentage increases at regular intervals. Example: A company has communicated to its employees an intention to increase all pay rates by 4% every four years initiated on every January 1st. Within the below arrays for pay rates, each element of the array represents a yearly pay raise. All employees climb the pay rate scale one element every year. The employee/app user will be able to toggle (Bool) on/off this option of regularly interval increases:
The full code is found here on GitHub. However, I am able to fit the entire macOS Line Command Tool code here...
In simple cases of array manipulation, the map method is a tried and true tool...
However, the above Is the map method the best tool for this more complex task? |
|
I have reorganized the GitHub repository. It should be much clearer now: "1.1.0 (Use This One)" is the code referenced above. The current print using a Command Line Tool project is as follows:
I appreciate any guidance you can provide to incorporate a regular pay raise function using a .map method or some other device. Thank you! |
|
Hi, The only way i could think of is if the years until retirement is larger than the pay rate scale then append the last number X ammount of times.
and to multiply every 4th element of the array using .map i would use an index.
So the hole thing would look like this:
Hopefully that's what your looking for. |
|
@Hectorcrdna Thank you! This is a step in the right direction but there is major problem. The pay raise is only applied to the 4th, 8th, 12th, etc. The pay raise needs set a new standard. Meaning the 4% pay raise does not only apply to the 4th year but also all the years following. When we put your code in the Playground, it transforms the array from:
to:
Notice how the fifth element is 28 in both arrays. The fifth element should be 28 1.04. The sixth element should be 30 1.04. The eighth element should be 34 1.04 1.04. |
|
Ok, i think i understand, try with this one.
|
|
@Hectorcrdna Yes!! Perfect! Thank you! Now how do I apply this into my code that is in my original post? |
|
Uff... I'm not sure, i think you would need to re-structure your code, turn the code above into a function and some how link the employees to this func, but i think you should Implement this in to the ios app instead of the command line since you're making the transition.
|
SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.