Hi techies,
Kindly help me the situation below:
//Interest.java
/*Mr. Brown invests $50,000.00 in a savings account yielding 5 percent interest.
* Assuming that all interest is left on deposit, write java codes to calculate and print
* the amount of money in the account at the end of each year for 10 years.
* Use the following formula for determining these amounts:
* a=P(1+r)n
* Where:
* P is the original amount invested i.e. the principal
* r is the annual interest rate
* n is the number of years
* a is the amount on deposit at the end of the nth year
* */
public class Interest {
public static void main(String[] args) {
double P=50000.00;
double r=0.05;
int n;
for(n=1; n<=10; n++);
System.out.println("The amount at the end of the first year is:" + P*(1+r));
/*this only prints the result for the first year and I would like to use this result as the principal for the second year and the subsequent for the 3rd year and so on..**/
}
}
Any help is appreciated
Thanks,
Bonny