try to :
1. input '66' and it will display four times.
2. input '567 , it works OK.
3. input '678', it will display five times.
4. input directly enter, it will display twice.
System.in.read() get the row keyboard input, that means it read the char of
'enter' too, and 'enter' is composed of 2 chars '\r\n'. you had better to take
java.io.BufferedReader for a substitution.