I am writing a program that is supposed to count the number of vowels in an inputted (by the user) body of text.
import java.util.*;
public class Vowels{
public static void main(String[] args){
Scanner console = new Scanner(System.in);
int counter= 0;
System.out.println("\nInput a sequence of characters");
String text = console.nextLine();
text = text.toLowerCase();
for (int loop = 0; loop < text.length(); loop++){
char lett = text.charAt(loop);
if (lett=='a' || lett=='e' || lett=='i' || lett=='o' || lett=='u') {
counter++;
}
}
System.out.println("There are " + counter + " vowels in the inputted text.");
}
}
Whenever I run this code, there's no input box for the user to input text.
If I change the "String text = console.nextLine();" to "String text = console.next();" then only the first word is taken into account.