title: How To Limit User Input In Java
body: <p>The amount of investment must be positive and can be any value.
  The period of investment is in years so should be positive.
  The annual rate of interest can be between 0.25% to 14%.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class InterestCalculator{
  
      /**
       * @param args the command line arguments
       */
      public static void main(String[] args) {
          // TODO code application logic here
  
          Scanner input = new Scanner(System.in);
  
          // Entering the interest rate
          System.out.print("Please Enter the annual interest rate between 0.25 to 10 : ");
          double annualInterestRate = input.nextDouble();
  
          double monthlyInterestRate = annualInterestRate / 1200;
  
          System.out.print("Enter number of years: ");
          int numberOfYears = input.nextInt();
  
          // Entering the amount earned
          System.out.print("Enter Amount: ");
          double Amountofinterest = input.nextDouble();
  
          // Calculating
          double moneyearned = Amountofinterest * monthlyInterestRate;
  
          // Displaying the results
          System.out.println("The money earned is $" +
          (int) (moneyearned * 100) / 100.0);
          int i;
  
          for (i = 1; i &lt;= numberOfYears * 12; i++) {
              double Balance = Amountofinterest + moneyearned;
              Amountofinterest = Balance;
              monthlyInterestRate = moneyearned + 0.01;
              System.out.println(i + "\t\t" + Amountofinterest
                      + "\t\t" + monthlyInterestRate + "\t\t" + Balance);
  
          }
  
      }
  }
  </code></pre>
  
  <p>I have made the basic program but, I don't know how to add restrictions.</p>