I am currently trying to make a simple program that will calculate the number of vowels in multiple sentences. The input looks like this:
6
Emily jumped high
Alex did not jump
Phillip hates jumping
The red dragon can fly
Sandwiches are nice
I like the sun
The number indicates how many lines there are. My problem is that when I print out the results, the last line gets ignored. So the program prints out 5 ints, rather than 6.For some reason when I posted the input, it would automatically show me the first 5 ints, I then just had to press enter to make the last one show up.
Scanner in = new Scanner(System.in);
int cases = in.nextInt(); //how many lines there are
String a;
int vowels = 0;
int length; //length of a line
char temp;
in.nextLine(); //skips first line of the input, as this declares how many lines there are
for (int i = 0; i < cases; i++)
{
a = in.nextLine();
length = a.length();
for (int b = 0; b < length; b++)
{
temp = a.charAt(b);
if (temp == 'a' || temp == 'e' || temp == 'i' || temp == 'o' || temp == 'u')
{
vowels++;
}
}
System.out.println(vowels);
vowels=0;
}