i really need help i 39 ve been coding for a while and i am not sure what he 39 s as 5154250
I really need help! I've been coding for a while and I am not sure what he's asking.
This is my code;
public static void main(String[] args){
int investments = 1000;
int deposit = 0;
int numberofYears = 25;
double interestRate = 6.5;
double currentBalance = 0;
double interest;
double newBalance;
System.out.println(“Year Deposit New Balance Interest”);
for (int i = 1; i
{
if (i==1)
{deposit = investments;
currentBalance = investments;
}
newBalance = currentBalance *Math.pow((1 + (interestRate/100)), 1);
interest = newBalance – currentBalance;
System.out.printf(“%5d %10d %20.2f %20.2fn”, i , deposit, currentBalance, interest, newBalance);
deposit = 100;
currentBalance = newBalance + deposit;
}
}
}
————————————————————————————————————
For this project, you are to complete the following assignment:
Programming Project #2, page 194
The problem statement reads as follows:
“A certain bank offers 6.5% interest on savings accounts, compounded annually. Create a table that shows how much money a person will accumulate over a period of 25 years, assuming the person makes an initial investment of $1000 and deposits $100 each year after the first year. For each year, your table should indicate the current balance, the interest, the new deposit, and the new balance.”
Use BlueJ to write the Java code for this project.
You should create a method to print the table that will be called from main(). This method should have parameters for the initial deposit, the number of years, the interest rate, and the yearly deposit.
When creating each line of the table, please be aware of the following:
The interest rate of 6.5% should be converted to a decimal value of 0.065 before being used in calculations.
The first line of the table should have column headers for the year, the interest amount, the deposit amount, and the new balance. You will need to use the t escape sequence to put spacing between the columns.
The initial deposit of $1000 should be listed by itself as the first row of the table.
For each of the 25 years, you should a for loop to calculate the balance as follows:
Calculate the interest by multiplying the interest rate by the previous year’s balance.
Add the interest amount and the $100 yearly deposit to the previous year’s balance to get the current year’s balance.
You need to find a way to round all calculated amounts to 2 decimal places. This might need to be done in another method. Suppose the variable n represents the amount to be rounded to 2 decimal places. Here is a formula that will do that:
(int) (n * 100) / 100.0;