I have a homework assignment where we have to make a very basic console app for a fitness center, that can create members and employees. My problem occurs when i ask the user to type in the birthday of the new members. It is supposed to check if the birthday is in the format DD/MM/YY, so i check if the answer given is 6 digits, and 6 digits only. And it seems to work, unless someone gives a birth date that start with 0, EG.: 090498.
System.out.println("Please enter the new members birthday, in the format of DD/MM/YY:");
this.birthdate = console1.nextInt();
while(String.valueOf(birthdate).length() != 6){
System.out.println("Please give a valid date of birth in the format of: DD/MM/YY");
this.birthdate = console1.nextInt();
}
It doesn't give a error message, but only completes the loop if the birthdate IS 6 digits, AND starts with a 1 EG.: 190798.
i know this is probably very simple, but i only started studying CS about a month ago :)