I would like to add a name to a queue (linked), one name at a time from a text file. If the user selects choice 1 then it should take the next name in from the lists.
Case 1 is not letting me input another choice if I want to add another name.
int choice = console.nextInt();
FileReader names = new FileReader("Customer.txt");
Scanner lookup = new Scanner(names);
Queue a = new Queue();
String customerName;
// This loop was just to verify that
while(lookup.hasNextLine() ){ // It was actually reading
customerName = lookup.next();
System.out.println(customerName);
}
while(true){
switch(choice){
case 1:
customerName = lookup.next();//For some reason its not giving me
a.enqueue(customerName); // The choice to enter another number
break; //even though I made the case while(true)
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
System.out.println(" Exiting......");
break;
default:
continue;
}
break;
}
breakafter your switch block, which terminates the while loop.