A savings account typically accrues savings using compound interest. If you depo
ID: 3721399 • Letter: A
Question
A savings account typically accrues savings using compound interest. If you deposit $1000 with a 10% interest rate per year, after one year you will have $1100. If you leave this money in the account for another year at 10% interest, you will have $1210. After three years you will have $1331, and so on. Write a program that inputs the initial amount , an aniterest rate per year, and the number of years the money will accrue compound interest. Write a recursive function that calculates the amount of money that will be in the savings account using the input information. • Use only one file for the program. Create a class name account. Add mutators and constructorsAdd as a member the recursive function for this project named finalamount() with three input values as described which returns the final savings amount after the interst is applied.A savings account typically accrues savings using compound interest. If you deposit $1000 with a 10% interest rate per year, after one year you will have $1100. If you leave this money in the account for another year at 10% interest, you will have $1210. After three years you will have $1331, and so on. Write a program that inputs the initial amount , an aniterest rate per year, and the number of years the money will accrue compound interest. Write a recursive function that calculates the amount of money that will be in the savings account using the input information. • Use only one file for the program. Create a class name account. Add mutators and constructorsAdd as a member the recursive function for this project named finalamount() with three input values as described which returns the final savings amount after the interst is applied.
A savings account typically accrues savings using compound interest. If you deposit $1000 with a 10% interest rate per year, after one year you will have $1100. If you leave this money in the account for another year at 10% interest, you will have $1210. After three years you will have $1331, and so on. Write a program that inputs the initial amount , an aniterest rate per year, and the number of years the money will accrue compound interest. Write a recursive function that calculates the amount of money that will be in the savings account using the input information. • Use only one file for the program. Create a class name account. Add mutators and constructorsAdd as a member the recursive function for this project named finalamount() with three input values as described which returns the final savings amount after the interst is applied.
Explanation / Answer
As per the understanding of your question, you are looking for compound interest.
Code:
// CompoundInterest.java
import java.util.*;
public class CompoundInterest
{
public static double calculateAmount(double amount,
double rate, int years)
{
if(years <= 0)
return amount;
else
return calculateAmount(amount * (1 + rate / 100),
rate, years - 1);
}
public static void main(String[] args)
{
Scanner console = new Scanner(System.in);
System.out.print(
"Enter the amount of money to deposit: $");
double P = console.nextDouble();
System.out.print("Enter an interest rate per year: $");
double i = console.nextDouble();
System.out.print("Enter the number of years: ");
int n = console.nextInt();
double finalAmount = calculateAmount(P, i, n);
System.out.printf(
" Final amount of money in the savings account: $%.2f", finalAmount);
}
}
Hope this helps. Thanks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.