I want to make it so that the user inputs some string, and the program takes console input until user types "/done".. so here's how it would work:
print to user: enter your string
user enters: hello eclipse.
hi test blah blah
bla 456 testmore /done
As soon as user enters /done within any string of any size, the program breaks. The program would NOT end if you hit "enter" key. It would only end if you type in /done.. How I setup my program so far:
Scanner 123 = new Scanner(System.in);
string input = "";
System.out.println("Enter your string: ");
do {
input = 123.nextLine();
System.out.print("Rest of program here..");
}
while (!input.equals("/done"));
I tried putting under while loop there something like below but I don't think I am doing it right.
while (!input.equals("/done"));
if input.equals("/done");
break;
}
I understand that with a do-while loop, it continues as long as boolean in while is false. So for my program, program takes inputs until user types in /done so boolean is false until string /done in inputted. Then according to the logic above, the program breaks as soon as input equals "/done"
Any ideas on what I'm doing wrong?