title: Why isnt my program printing out what i want it to?
body: <p>When I run my code my out put is this</p>
  <blockquote>
  <p>----jGRASP exec: java AgeClientFL</p>
  <p>Enter birth day: 5 Enter birth month: 5 Enter birth year: 5 Birth:
  5/5/5</p>
  <p>Today: 1/1/0 Age: 0</p>
  <p>Michaels Birth: 5/7/1995 Milestone: 5/7/2016
  Age at Milestone: 0</p>
  <p>----jGRASP: operation complete.</p>
  </blockquote>
  <p>For <code>Today</code> I had entered in 10/10/10 and I want it to come out as 10/10/10 but it came out as 1/1/0. For the first <code>age</code> I wanted to get out a 5 but got a 0. And <code>Age at Milestone</code> should have been a 21 not 0.</p>
  <p>Which parts of my code are causing these incorrect print outs and how can i fix them? Here is part 1 of the code i am using.</p>
  <pre><code>import java.text.*;
  import java.util.Date;
  public class AgeClientFL {
  
  public static void main(String [] args){
  
    int month, day, year, age;
    
    
    day = UtilsFL.readInt(&quot;Enter birth day: &quot;,false); // String mode
    month = UtilsFL.readInt(&quot;Enter birth month: &quot;,false);
    year = UtilsFL.readInt(&quot;Enter birth year: &quot;,false);
    
    SimpleDate dateBirth = new SimpleDate(month,day,year);
    
    System.out.println(&quot;Birth: &quot; + dateBirth);
    
    day = UtilsFL.readInt(&quot;Enter todays day: &quot;,true); // JOptionPane mode
    month = UtilsFL.readInt(&quot;Enter todays month: &quot;,true);
    year = UtilsFL.readInt(&quot;Enter todays year: &quot;,true);
    
    SimpleDate dateToday = new SimpleDate(month,day,year);
    
    System.out.println(&quot;Today: &quot; + dateToday);
    
    age = UtilsFL.getAge(dateBirth,dateToday);
    System.out.println(&quot;Age: &quot; + age);
    
    month = 5;
    day = 7;
    year = 2016;
    SimpleDate milestone = new SimpleDate(month,day,year);
    month=5;
    day=7;
    year=1995;
    SimpleDate bdMilestone = new SimpleDate(month,day,year);
    int mAge;
    mAge = UtilsFL.getAge(bdMilestone, milestone);
    System.out.println(&quot;Michaels Birth: &quot; + bdMilestone);
    System.out.println(&quot;Milestone: &quot; + milestone);
    System.out.println(&quot;Age at Milestone: &quot; + mAge);
    
  }
  }
  </code></pre>
  <p>And here is part two.</p>
  <pre><code>import java.util.GregorianCalendar;
  import java.util.Date;
  import javax.swing.JOptionPane;
  import java.util.Scanner;
  import java.util.Calendar;    
  
  public class UtilsFL {
  
  
  public static int readInt(String prompt,boolean guiFlag) {
  
      if (guiFlag==false){
      Scanner input = new Scanner(System.in);
      int data;
      
      System.out.print(prompt);
      data = input.nextInt();
      
      return data;
      }
      else if (guiFlag==true) {
      int data;
      data = Integer.parseInt(JOptionPane.showInputDialog(prompt));
      }
      return 0;
      
    }      
      
  
  
  
  public static SimpleDate today() {
  
  
      Calendar todayCal = Calendar.getInstance();
      SimpleDate todayDate = new SimpleDate();
      
  
      todayDate.setDate(todayCal.get(Calendar.MONTH) + 1, 
                        todayCal.get(Calendar.DATE),
                        todayCal.get(Calendar.YEAR));
      return todayDate;
  }
  
  
  public static int getAge(SimpleDate dateBd) {
      int age;
      SimpleDate dateToday = today();
      
      
      age = getAge(dateBd, dateToday);  
      return age;
      
  } 
  
  public static int getAge(SimpleDate dateBd, SimpleDate dateRef) {
    Calendar cal = new GregorianCalendar ();
    Calendar now = new GregorianCalendar();
      int rAge = now.get(Calendar.YEAR) - cal.get(Calendar.YEAR);
   if((cal.get(Calendar.MONTH) &gt; now.get(Calendar.MONTH)
     || (cal.get(Calendar.MONTH) == now.get(Calendar.MONTH)
     &amp;&amp; cal.get(Calendar.DAY_OF_MONTH) &gt; now.get(Calendar.DAY_OF_MONTH))))
   {
      rAge--;
   }
      return rAge;
      
      
  }
          
  }
  </code></pre>
  <p>I think it might be a problem with the <code>public static int getAge</code> at the bottom of part two of my code. but im not sure and i cant figure out how to fix it.</p>
  <p>Here is the code for the SimpleDate class that is referenced in some of my previous code.</p>
  <pre><code>import java.io.Serializable;        // for object I/O to file
  
  //public class SimpleDate
  public class SimpleDate implements Serializable
  
  {
    private int month;
    private int day;
    private int year;
  
    /** default constructor
    *  sets month to 1, day to 1 and year to 2000
    */
    public SimpleDate( )
    {
      setDate( 1, 1, 2000 );
    }
  
    /** overloaded constructor
    *  @param mm    initial value for month
    *  @param dd    initial value for day
    *  @param yyyy  initial value for year
    *
    *  passes parameters to set methods
    */
    public SimpleDate( int mm, int dd, int yyyy )
    {
      setMonth( mm );
      setYear( yyyy );
      setDay( dd );
    }
  
    /* accessor methods */
    int getMonth( ) { return month; }
    int getDay( )   { return day; }
    int getYear( )  { return year; }
  
    /** mutator method */
    /** setMonth
    *  @param mm new value for month
    *  if mm is between 1 and 12, sets month to mm
    *  otherwise, sets month to 1
    */
    public void setMonth( int mm )
    {
      month = ( mm &gt;= 1 &amp;&amp; mm &lt;= 12 ? mm : 1 );
    }
  
    /** setDay
    *  @param dd new value for day
    *  if dd is legal day for current month, sets day to dd
    *  otherwise, sets day to 1
    */
    public void setDay( int dd )
    {
      day = ( dd &gt;= 1 &amp;&amp; isValidDay( dd ) ? dd : 1 );
    }
  
    /** setYear
    *  @param yyyy new value for year
    *  sets year to yyyy
    */
    public void setYear( int yyyy )
    {
      year = yyyy;
    }
  
    /** sets date to the next day
    */
    public void nextDay( )
    {
       if ( ! isValidDay( ++day ) )
       {
           day = 1;
           if ( ++month &gt; 12 )
           {
               month = 1;
               year++;
           }
       }
    }
  
    private boolean isValidDay( int newDay )
    {
       int [] daysInMonth = { 0, 31, 28, 31,
                                  30, 31, 30,
                                  31, 31, 30,
                                 31, 30, 31 };
  
      if ( newDay &gt; daysInMonth[month] )
      {
         if ( month == 2 &amp;&amp; isLeapYear( ) &amp;&amp; newDay == 29 )
            return true;
         else
            return false;
      }
      else
         return true;
  
    }
  
    private boolean isLeapYear( )
    {
       return !( year % 4 != 0
                 ||( year % 100 == 0 &amp;&amp; year % 400 != 0 ) );
    }
  
  
    /** setDate
    *  @param mm    new value for month
    *  @param dd    new value for day
    *  @param yyyy  new value for year
    *  passes parameters to setMonth, setDay, and setYear
    */
    public void setDate( int mm, int dd, int yyyy )
    {
      setYear( yyyy );  // set year first (could be leap year)
      setMonth( mm );   // set month next
      setDay( dd );     // set day
    }
  
    /** toString
    *  @return String
    *  returns date in mm/dd/yyyy format
    */
    public String toString( )
    {
      return month + &quot;/&quot; + day + &quot;/&quot; + year;
    }
  
    /** equals
    *  @param   d  Object to compare to this object
    *  @return  true if d is equal to this object
    *           false, otherwise
    */
    public boolean equals( Object d )
    {
      if ( !( d instanceof SimpleDate ) )
         return false;
      SimpleDate d1 = (SimpleDate)d;
      if ( month == d1.month
           &amp;&amp; day == d1.day
           &amp;&amp; year == d1.year )
        return true;
      else
        return false;
    }
  }
  </code></pre>