I made a scanner which asks for 3 integer : month / day / year of birth For every integer, i check if this is a valid entry (i.e month <12 & month >0). If three entrees are valid i do a :
System.out.println(month + "-" + day + "-" + year);
full code following :
// TODO code application logic here
Scanner sc = new Scanner(System.in);
int intJour;
int intMois;
int intAnnee;
do {
System.out.println("Year of birth :");
intJour = sc.nextInt();
sc.nextLine();
} while (intJour < 0 || intJour > 31);
do {
System.out.println("Month of birth :");
intMois = sc.nextInt();
sc.nextLine();
} while (intMois < 0 || intMois > 12);
do {
System.out.println("Year of birth :");
intAnnee = sc.nextInt();
sc.nextLine();
} while (intAnnee < 0 || intAnnee > Calendar.getInstance().get(Calendar.YEAR));
System.out.println("Birth date: " + intJour + "-" + intMois + "-" + intAnnee);
I would like to make a date out of the user inputs, and check if that date existed. I.E not every month has a 31 regarding of the year involved.