|
I'm using macOS Command Line Tool to work out the formulae before transitioning to an app. The current short-term goal is to print an employee's yearly earnings based on hours worked per month and an array of increasing pay rates correlating with the employee's years working for the company. Element #1 will be the pay rate for year 1, #2 for year 2, etc. My current code only calculates annual earnings using the tenth element because I have used
. Consequently the print shows the same amount of annual earnings for every year: $72,960 (160 hours x 12 months x 38 hours worked). I'm not sure how to make this dynamic. Any ideas?
|
|
Something like this, perhaps?
I have to confess to being a bit confused trying to figure out your original code. I hope I've got the right idea what you are going for. Here's the output:
|
|
@roosterboy That's perfect! I'm super new to coding which may explain the chaotic nature of my original code. Thank you for your help! If $40/hr is the last pay rate that applies to all years of employment after reaching that year (11th year of employment), is there a way to make $40/hr the default? Perhaps replace the fatal error with "40"? |
|
Yep, just change
|
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
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.