title: Java Compound Interest Calculator
body: <p>I am currently working on a Java compound interest calculator. I am extremely new to Java and this project has been very challenging and I now find myself at a brick wall.</p>
  
  <p>I fear I am doing something fundamentally wrong that I should know (did I put something in the wrong place?)</p>
  
  <p>I get an 'illegal start of type' error next to my line:</p>
  
  <pre><code>for ( int i = 0; i&lt;period; i++)
  </code></pre>
  
  <p>I think I may need to place this inside a method? Here's my full code.</p>
  
  <p>Account.java:</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  public class Account extends JFrame {
  
  private int period;
  private int balance;
  private int rate;
  private String printstring;
  
  @Override
  public String toString() {
      return String.format("Period: " + period + ", Balance: " + balance);
  }
  
  public int getPeriod() {
      return period;
  }
  
  public void setPeriod(int period) {
      this.period = period;
  }
  
  public int getBalance() {
      return balance;
  }
  
  public void setBalance(int balance) {
      this.balance = balance;
  }
  
  public int getRate() {
      return rate;
  }
  
  public void setRate(int rate) {
      this.rate = rate;
  }
  
  public String getPrintstring() {
      return printstring;
  }
  
  public void setPrintString(String printstring) {
      this.printstring = printstring;
  }
  
  
  for ( int i = 0; i&lt;period; i++)
  {
      balance = (balance * rate) + balance;
  }
  }
  </code></pre>
  
  <p>Banker.java</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  public class Banker {
  
  private static final int H = 400;       // Height of window pixels
  private static final int W = 500;       // Width  of window pixels
  
  public static void main(String[] args) {
  
      String period;
      String balance;
      String rate;
  
      period = JOptionPane.showInputDialog(null, "Interest period:");
      balance = JOptionPane.showInputDialog(null, "Current balance:");
      rate = JOptionPane.showInputDialog(null, "Interest rate:");
      JFrame frame = new JFrame("Savings Interest Calculator");
      JButton calculate = new JButton("Calculate");
      JLabel blabel = new JLabel("Period: " + period);
      JLabel plabel = new JLabel("Balance: " + balance);
      JLabel flabel = new JLabel("Balance: " + balance);
      frame.setLayout(new FlowLayout());
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.add(calculate);
      frame.add(plabel);
      frame.add(blabel);
      frame.pack();
      frame.setVisible(true);
  }
  
  
  }
  </code></pre>