Question
Create a Java file called CompoundInterestYourLastName. Write a method called computeBalance( ) that computes the balance of a bank account with a given initial deposit,
Create a Java file called CompoundInterestYourLastName. Write a method called computeBalance( ) that computes the balance of a bank account with a given initial deposit, annual interest rate, after a given number of years for the investment. Assume interest is compounded yearly.
The formula for determining compound interest (compounded yearly) is:
A=P(1+r) to the power of t
where:
- A = the future value of the investment/loan, including interest
- P = the principal investment amount (the initial deposit or loan amount)
- r = the annual interest rate (decimal)
- t = the time the money is invested or borrowed for
Create your method to accept three parameters in this order: initial deposit, annual interest rate as a decimal, after a given number of years.
Your method should return a double value of the future value including interest.
In your main method, run the following tests to verify your method is working correctly.
System.out.printf("Your total is $%.2f", computeBalance(10000, .045, 13));
// should return $17721.96
System.out.printf(" Your total is $%.2f", computeBalance(20000, .03, 15));
// should return $31159.35
System.out.printf(" Your total is $%.2f", computeBalance(30000, .01, 20));
// should return $36605.70
Pay close attention to your parameters to make sure they match the test data!
Your methods should have this exact signature line, including the correct spelling, capitalization and parameter types.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started