the purpose of this code is to check and see if the date is valid. this is only the first part. i am stuck, because if i enter an invalid date, it only goes through twice, then ends (and doesn't output anything...). if i enter a valid one, it works perfectly fine! any ideas as to what is wrong with my loop?
Code:import java.util.Scanner;
public class DateValidationConversion
{
public static void main(String[]args)
{
String curDate = "";
char firstDateValidation = ' ';
char nextDateValidation = ' ';
String curMonth = "";
String curDay = "";
boolean validDate = false;
int dateLength = 0;
//Prompts user for the date
Scanner in = new Scanner(System.in);
System.out.println("Please enter the current date in MM/DD/YYYY format (including 0's): ");
curDate = in.next();
dateLength = curDate.length();
firstDateValidation = curDate.charAt(2);
nextDateValidation = curDate.charAt(5);
if (firstDateValidation == '/' && nextDateValidation == '/' && dateLength == 10)
{
validDate = true;
curMonth = curDate.substring(0,2);
curDay = curDate.substring(3,5);
System.out.println ("This is a valid date.");
if (curMonth.equals("02") && curDay.equals("29"))
{
System.out.println("This IS a leap year!");
}
}
else
{
//Prompts user for the date
System.out.println("Please enter the current date in MM/DD/YYYY format (including 0's): ");
curDate = in.next();
}
}
}

