How To Make a Age Calculator in Java

This is a age calculator made in java, it's a console application by the way :)

source :

 import java.util.GregorianCalendar;
import java.util.Scanner;
import java.util.InputMismatchException;

public class age_calculator {

    public static void main(String[] args) {
        int day = 0;
        int month = 0;
        int year = 0;
        Scanner scan = new Scanner(System.in);
  try{
         System.out.print("Day: ");
         day = scan.nextInt();
         System.out.print("Month: ");
         month = scan.nextInt();
         System.out.print("Year: ");
         year = scan.nextInt();
  }
  catch(InputMismatchException e){
   System.out.println("Error: You entered an invalid number");
   System.exit(1);
  }
        System.out.println("\nYou are " + getAge(day,month,year) + " years old");
    }

    public static int getAge(int day, int month, int year){
  final int ERROR = -1;

        //initialize GregorianCalendar with current date
        GregorianCalendar cal = new GregorianCalendar();
        //constant holds current day
        final int CDAY = cal.get(GregorianCalendar.DAY_OF_MONTH);
        //constant hold current month
        final int CMONTH = cal.get(GregorianCalendar.MONTH) + 1;
        //constant to hold current year
        final int CYEAR = cal.get(GregorianCalendar.YEAR);
        //check if current day of the month is greater then birth day
        if (month == CMONTH){
            if(CDAY >= day)
                return CYEAR - year;
   if(CDAY < day)
    return CYEAR - year - 1;
        }
        //check if birth month is less then current month
        else if(month < CMONTH)
            return CYEAR - year;
        //subtract 1 from the age because  the current day in the month is less then birth date
  else
         return CYEAR - year - 1;
  return ERROR;
    }

} 

screenshot :
 How To Make a Age Calculator in Java
 Hope it helped you :)

How To Make A Addition Calculator In Java Using JOption

How To Make A Addition Calculator In Java Using JOption
Okay guys today i will be teaching you how to make a simple addition calculator using Joption in java, I saw someone wrote some codes to calculate addition also it uses Java Scanner. This is that program .
import java.util.Scanner;

class basic_cal
{
  public static void main(String args[])
  {
   Scanner shim = new Scanner(System.in);
   double first_number,second_number,answer;
   System.out.println("Enter First Number : ");
   first_number = shim.nextDouble();
   System.out.println("Enter Second Number : ");
   second_number = shim.nextDouble();
   answer = first_number + second_number;
   System.out.println("Answer : " + answer);
   }
}   
Okay now i saw that and got an idea to make the same thing with Joption , Joption is like the messagebox we have in c# and vb.net ok , this is the program i wrote :