can someone help me with my code. I am trying to design a code that will generat
ID: 3652569 • Letter: C
Question
can someone help me with my code. I am trying to design a code that will generate an output that is used to create a chart that represents the amount of money a person will accumulate over a period of time, starting with the initial of $ 1000 deposit, and the deposit of $100 dollars each year after with 6.5 %interest annually?
public class money {
public static void main(String[] args) {
int deposit = 1000;
int initialdeposit = 0;
double interestrate = 6.5;
double currentvalue =0;
double interest ;
double newbalance;
int years = 25;
System.out.println("years currentbalance interest new balance ");
for( int i=1; i<= years; i++ ) {
{
initialdeposit = deposit;
currentvalue = deposit;
}
newbalance =currentvalue*Math.pow((1+(interestrate/100)), 1);
interest = newbalance - currentvalue;
System.out.println(years + " " + currentvalue + " " + interest + " " + newbalance );
deposit = 100;
currentvalue = newbalance + deposit;
}
}
}
Explanation / Answer
Program:
=====================================================
public class money {
public static void main(String[] args) {
int deposit = 1000;
int initialdeposit = 0;
double interestrate = 6.5;
double currentvalue =deposit;
double interest ;
double newbalance;
int years = 25;
System.out.println("years||currentbalance||interest||new balance ");
System.out.println("============================================");
for( int i=1; i<= years; i++ )
{
newbalance =currentvalue*Math.pow((1+(interestrate/100)), 1);
interest = newbalance - currentvalue;
System.out.printf(" %d %.2f %.2f %.2f ",i,currentvalue,interest,newbalance);
deposit = 100;
currentvalue = newbalance + deposit;
}
}
}
======================================================
Sample output:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.