Taking a users input in a library class and making sure it is positive
<p>Here are my two java files that I am working with. The problem I am having is getting the getPosNum method (highlighted below) to take the number the user inputs and see if that number is positive rather than doing what is doing right now, which is: </p>

<blockquote>
  <p>jGRASP exec: java Prog12<br>
  OUTPUT: First Investment<br>
  INPUT: Please enter a positive number: -5000.00<br>
  INPUT: ERROR: -5000.0 is not positive; try again: -3000.00  </p>
</blockquote>

<p>Rather than getting it to say something like this:</p>

<blockquote>
  <p>jGRASP exec: java Prog12<br>
  OUTPUT: First Investment<br>
  INPUT: Enter the first principal amount: -5000.00<br>
  INPUT: ERROR: -5000.0 is not positive; try again: -3000.00  </p>
</blockquote>

<p>How can I fix this problem and make it read correctly? Am I making sense? </p>

<pre><code>public class Finance
{
   public static double getPosNum (String prompt)
   {
      double num;
      num = Input.readDouble("Please enter a positive number: ");
      while (num &lt;= 0.0)
         num = Input.readDouble("ERROR: " + num + 
            " is not positive; try again: ");
      Output.showValue("You entered ", num);

      return num;

   } // method getPosNum

   public static void outFinances (double prin, double rate, double years, double fv)
   {
      Output.showMessage("The original amount invested was $" + prin + ",\nand the annual interest rate was set at " + rate + "%.\nIt has been " + years + " years since the investment was made,\nand the future value of the investment after that many years is $" + fv + ".");

   } // method outFinances

   public static double futureValue (double prin, double rate, double years)
   {
      double FV, P, r, n;
      P = prin;
      r = rate;
      n = years;
      FV = P * Math.pow((1 + (r / 100)),(n));
      return FV;

   } // method outFinances

} // class Finance

// File: Prog12.java
// CS200 Lab 12 Main
// Author: Ryan Pech
// Created: February 19, 2011

public class Prog12
{
   public static void main (String [] args)
   {
      double p, r, y, fv;

      Output.showMessage("First Investment");
      p = Finance.getPosNum("Enter the first principal amount: ");
      r = Finance.getPosNum("Enter the first interest rate: ");
      y = Finance.getPosNum("Enter the first number of years: ");
      fv = Finance.futureValue(p, r, y);
      Finance.outFinances(p, r, y, fv);

      Output.showMessage("Second Investment");
      p = Finance.getPosNum("Enter the second principal amount: ");
      r = Finance.getPosNum("Enter the second interest rate: ");
      y = Finance.getPosNum("Enter the second number of years: ");
      fv = Finance.futureValue(p, r, y);
      Finance.outFinances(p, r, y, fv);

  } // method main

} // class Prog12


// File: Finance.java
// CS200 Lab 12
// Author: Ryan Pech
// Created: February 19, 2011
</code></pre>
