flyingcurry 0 Light Poster

The below method is for my database assignment, and we are supposed to check if the "username" the user adds is already in the database.
Somehow "newRecord.username = sc.nextLine();" this line does not work, the second time through the do-while loop
It seems like it just ignores the line or something, sample output is in red.


Sample Input:
Username: Joe
Hometown: Pallet Town
Gender: M
Specialty: Fire

Username: Usernamehoho: null
alice
Usernamehoho: alice
The username 'alice' already exist in the database.
Choose from the menu below.
(1)Enter a database with a different username
(2)Replace the existing record with the new one
(3)Quit program
1
case1 reached.
Username: Usernamehoho: alice
Usernamehoho:
Hometown: WTF!!!

-------------------------------------------------
Here is my code

public static TrainerRecord getRecord() throws IOException {
		TrainerRecord newRecord = new TrainerRecord();


		System.out.println("Sample Input: ");
		System.out.println("Username: Joe");
		System.out.println("Hometown: Pallet Town");
		System.out.println("Gender: M");
		System.out.println("Specialty: Fire");



		Scanner sc = new Scanner(System.in);


		System.out.println("");

		boolean duplicate=false;
		do
		{
			System.out.print("Username: ");
                        System.out.println("Usernamehoho: "+newRecord.username);
			newRecord.username = sc.nextLine();
			//WHY DOES IT SKIP THIS LINE

                        System.out.println("Usernamehoho: "+newRecord.username);

			if((search(0, dataNumbers-1, newRecord.username))!=-1)
			{
				System.out.println("The username '"+newRecord.username+"' already exist in the database.");
				System.out.println("Choose from the menu below.");
				System.out.println("\t(1)Enter a database with a different username");
				System.out.println("\t(2)Replace the existing record with the new one");
				System.out.println("\t(3)Quit program");

				switch (sc.nextInt()) {
				case 1:
					//System.out.println("case1 reached.");
					duplicate=true;
					break;
				case 2:
					//System.out.println("case2 reached.");
					duplicate=false;
					break;
				}
			}
			else
			{
				duplicate=false;
			}
		}while (duplicate==true);


		System.out.print("Hometown: ");
		newRecord.hometown = sc.nextLine();
		System.out.print("Gender: ");
		newRecord.gender = sc.nextLine();
		System.out.print("Specialty: ");
		newRecord.specialty = sc.nextLine();


		return newRecord;
	}