HELP FAST!!----Interest Calculator

Hey guys. Im new to here and new to Java. My class is doing a simple assignment to compute interest on a initial deposit in the bank for 1,5,10,20,30 years. I have to print the current balance at the end of each time frame. I cant figure out how to get the interest for each month COMPOUNDED upon each other. For example) a deposit of $100 at .01 interest would not be $112 at the end of year 1, it would be more because you earn interest on the interest already earned for every month. I think i need to do a loop but Im not sure. HELP WITH SINTAX!!!!!!

1) First of all, please take a deep breath and try to calm down. Yelling in your post is not going to endear you to those who might otherwise help you.
2) Please show us your code attempt and problems with it, how it doesn't work, what specific errors it shows.

Also, when posting your code, please use code tags so that your code will retain its formatting and be readable. To do this, you will need to paste already formatted code into the forum, highlight this code, and then press the "code" button. Another way is to place the tag &#91;code] at the top of your block of code and the tag &#91;/code] at the bottom, like so:

Java Code:

&#91;code]
// your code block goes here.
// note the differences between the tag at the top vs the bottom.
&#91;/code]

//Import your JOptionPane to enable your program to run the dialog box.
import javax.swing.JOptionPane;
//Assign your program a class name which must match your save name.
class interest
{
public static void main(String[] args)
{
//Assign the correct keywords to your values in the program. I used double to represent dollar amounts
//with 2 places. I used int for my months which will be suffecient for an account that is open for a
//long time.
double interestRate;
double balance;
double interestEarned;
double newBalance;
int numberMonths;
//I used string temp to enable me to convert the input amount in the dialog box into a double.
String temp;

//After the input is typed into the dialog box, the amount is put in double form. This input box
//assigns the Initial Deposit put into the account.
temp = JOptionPane.showInputDialog(null,"What is your initial deposit into your account?");
balance = Double.parseDouble(temp);

//After the input is typed into the dialog box, the amount is put in double form again. This input box
//assigns the APR given to the account.
temp = JOptionPane.showInputDialog(null,"What is your Expected APR on your account?");
interestRate = Double.parseDouble(temp);

//This prints the Initial Deposit on the screen.
System.out.println(balance);

//This calculates the New Balance after 1 year has passed and the APR has been compounded to the Initial
//Deposit of the account. The New Balance after compounding is printed to the screen.
numberMonths = 12;
newBalance=(balance+(balance*interestRate*numberMo nths));
System.out.println(newBalance);

//This calculates the New Balance after 5 years have passed and the APR has been compounded to the Initial
//Deposit of the account. The New Balance after compounding is printed to the screen.
numberMonths = 60;
newBalance=(balance+(balance*interestRate*numberMo nths));
System.out.println(newBalance);

//This calculates the New Balance after 10 years have passed and the APR has been compounded to the
//Initial Deposit of the account. The New Balance after compounding is printed to the screen.
numberMonths = 120;
newBalance=(balance+(balance*interestRate*numberMo nths));
System.out.println(newBalance);

//This calculates the New Balance after 20 years have passed, and the APR has been compounded to the
//Initial Deposit of the account. The New Balance after compounding is printed to the screen.
numberMonths = 240;
newBalance=(balance+(balance*interestRate*numberMo nths));
System.out.println(newBalance);

//This calculates the New Balance after 30 years have passed, and the APR has been compounded to the
//Initial Deposit of the account. The New Balance after compounding is printed to the screen.
numberMonths = 360;
newBalance= (balance+(balance*interestRate*numberMonths));
System.out.println(newBalance);
}
}

Have you tried working out the problem on a piece of paper first to see how the calculations flow? You should be able to see a pattern as you work it step by step that will help you decide how to code a loop.

fishtoprecords will have a lot to say about this question. He'll recommend (and rightfully so) that you should never use floating point numbers to represent currency, though you may have no choice here if your instructor requires that you do so.