I am trying to write an algorithm to calculate salary, that will receive a 3% raise every year. If making $20,000 this year, the salary next year would be $20,600 ($20,000 + ($20,000)*.03)) and $21,218 the year after ($20,600 + ($20,600 * .03)), $21,854.54 the year after ($21,218 + ($21,218 * .03)), etc. I want to do this up to $30,000.
I want to write it so I can compute for a salary of 30k after any number of years.
Here is some code I wrote that is completely wrong which is why I am seeking help.
You might find it useful to write out your methodolgy as comments, then go back and write th code.
This can be done incrementally - so write a few general ideas, then go back and insert more detail. When you are happy, write the code - leave the comments as they form documentation.
To make it easy to start with - hard code the values (put the values into the code) - when that is working, change it so that it asks for input from the user.
So you need to think about which variables you need and their types (double would be good)
Next a formula to calculate the answer - freddy92 provided a big clue.
Most importantly - you need to do a lot of reading. There is the reference section - top left of this page. There is Google & Wiki. Also try the first 4 chapters of this book - will give a good idea on the basics: