I am currently working on a date difference program for school, and I cannot figure out why it entirely skips over the "secondMonth" input. It prints out the final lines but will only accept input for the "secondYear" and breaks the program. I wrote the program in Eclipse and I am compiling it within Eclipse. Any help would be very much appreciated.
My code:
if (secondMonth.equalsIgnoreCase("janurary"))
{
secondMonthNumber = 1;
}
else if (secondMonth.equalsIgnoreCase("february"))
{
secondMonthNumber = 2;
}
else if (secondMonth.equalsIgnoreCase("march"))
{
secondMonthNumber = 3;
}
else if (secondMonth.equalsIgnoreCase("april"))
{
secondMonthNumber = 4;
}
else if (secondMonth.equalsIgnoreCase("may"))
{
secondMonthNumber = 5;
}
else if (secondMonth.equalsIgnoreCase("june"))
{
secondMonthNumber = 6;
}
else if (secondMonth.equalsIgnoreCase("july"))
{
secondMonthNumber = 7;
}
else if (secondMonth.equalsIgnoreCase("august"))
{
secondMonthNumber = 8;
}
else if (secondMonth.equalsIgnoreCase("september"))
{
secondMonthNumber = 9;
}
else if (secondMonth.equalsIgnoreCase("october"))
{
secondMonthNumber = 10;
}
else if (secondMonth.equalsIgnoreCase("november"))
{
secondMonthNumber = 11;
}
else
{
secondMonthNumber = 12;
}
System.out.print("Enter year: ");
secondYear = scan.nextInt();
System.out.print("These dates are " + (firstYear - secondYear) + "years and " + (firstMonthNumber - secondMonthNumber) + "months apart.");