What loop should I use?

I am supposed to do a word-quiz game between two languages in Java, and I am not sure what type of loop should be used when controlling the input from the user! I have three "conditions/terms"

  1. if the user types the right answer
  2. if the user has some spelling mistake
  3. if the user types q to quit the game

I was first thinking of using a for loop, but I don't seem to figure it out!

My code looks like this right now

public static int takeTest(ArrayList<Sweng> Wordlist) {
        int result = 0;
        Scanner keyboardInput = new Scanner(System.in);
        for (int i = 0; i < Wordlist.size(); i++) {
            String answer = keyboardInput.nextLine();

Read more here: https://stackoverflow.com/questions/68485467/what-loop-should-i-use

Content Attribution

This content was originally published by Emma at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: