title: How to tackle this compound interest homework?
body: <p>I have been given an assignment:</p>
  <blockquote>
  <p>Write a recursive method that given an initial amount of investment ($) and the interest rate and the number of years, it calculates the amount at the end of n years. Note that the interest is compounded annually.</p>
  <p>Use the following method signature</p>
  <pre><code>public static double invest(double amount, double rate, int year)
  </code></pre>
  <p>where</p>
  <ul>
  <li>amount is the investment amount</li>
  <li>rate is the annual interest rate</li>
  <li>year is the number of years of investment</li>
  </ul>
  <p>For instance</p>
  <ul>
  <li>invest(2000, 0.07, 1) returns 2140</li>
  <li>invest(5000, 0.05, 10) returns 8144.47313 (some digits are omitted for brevity)</li>
  </ul>
  <p>Then write a program to test your method.</p>
  </blockquote>
  <p>This is my programs</p>
  <pre><code>public class Investment {
  
      public static void main(String[] args) {
          System.out.println(invest(2000, 0.07, 1));
  
      }
  
      public static double invest(double amount, double rate, int year) {
          if (amount == 0 || rate == 0 || year == 0) {
              return 0;
          } else {
              return amount * (1 + (rate * year));
          }
      }
  }
  </code></pre>
  <p>Problem is, I do not know if it is recursive method or not and if not. Can you please tell me how to do it?</p>