title: So I have this code here, it calculates the vowels in a given phrase. I'm trying to get it to repeat if the user says yes
body: <p>I was wondering as to how I could get the end of the program to repeat if the user does respond with a 1. Do I need to reorganize it so that it is part of the if statement?</p>
  
  <pre><code>Scanner input = new Scanner(System.in);
  
  System.out.println("Count Vowels \n============");
  System.out.println("Type a sentence and this program will tell you\n\nhow many vowels there are (excluding 'y'):");
  String string1;
  
  string1 = input.nextLine();
  string1 = string1.toLowerCase();
  int vowels = 0;
  int answer;
  int i = 0;
  
  for (String Vowels : string1.split(" ")) {
      for (i = 0; i &lt; Vowels.length(); i++) {
  
          int letter = Vowels.charAt(i);
  
          if (letter == 'a' || letter == 'e' || letter == 'i' || letter == 'o' || letter == 'u') {
              vowels++;
          }
      }
  
      System.out.println(Vowels.substring(0, 1).toUpperCase() + Vowels.substring(1) + " has " + vowels + " vowels");
      vowels = 1;
  }
  
  System.out.println("Would you like to check another phrase in the Vowel Counter? if so Press 1 if not press 2");
  answer = input.nextInt();
  
  if (answer == 1) {
      System.out.println("You have chosen to count the vowels in another phrase");
  } else {
      System.out.println("Have a nice day");
  }
  </code></pre>