title: Compounding interest program in Java
body: <p>I'm trying to write this compounding interest program with a do while loop at the end and I cannot figure out how to print out the final amount. </p>
  
  <p>Here is the code I have so far : </p>
  
  <pre><code>public static void main(String[] args) {
      double amount;
      double rate;
      double year;
  
      System.out.println("This program, with user input, computes interest.\n" +
      "It allows for multiple computations.\n" +
      "User will input initial cost, interest rate and number of years.");
  
      Scanner keyboard = new Scanner(System.in);
  
      System.out.println("What is the initial cost?");
      amount = keyboard.nextDouble();
  
      System.out.println("What is the interest rate?");
      rate = keyboard.nextDouble();
      rate = rate/100;
  
      System.out.println("How many years?");
      year = keyboard.nextInt();
  
  
      for (int x = 1; x &lt; year; x++){
          amount = amount * Math.pow(1.0 + rate, year);
                  }
      System.out.println("For " + year + " years an initial " + amount + " cost compounded at a rate of " + rate + " will grow to " + amount);
  
  
      String go = "n";
      do{
          System.out.println("Continue Y/N");
          go = keyboard.nextLine();
      }while (go.equals("Y") || go.equals("y"));
  }
  </code></pre>
  
  <p>}</p>