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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!