Chris Hathaway wrote:im making a program that compares the dates and tells you how far apart they are timewise. im having a small problem at the moment thought...
here is part of my code:
------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
what it should do is
1. print "For the first date..."
then "enter month:" right under it
2. wait for user input
3. print "Enter year:"
4. wait for input
but on the second section of code, where it uses monthnumbertwo and yearnumbertwo, its displaying "Enter Year:" and "Enter Month:" at the same time. I have no idea what the problem is...
The issue is at line 5. Remember that the nextInt() method reads the next int -- unlike nextLine() it doesn't read the CR which ends the line. So, the nextInt() method reads the int, but leaves the CR character, which is immediate taken by the next nextLine() call. This is why you get a "Emter month:" immediately followed by "Enter Year:".
Henry