r/javahelp • u/Darknight03 • Feb 21 '19
Need help with Java Code!!!
Here is my code:
import java.util.Scanner;
public class VowelCount
{
public static void main(String args [])
{
int a = 0, e = 0, i = 0, o = 0, u = 0, other = 0;
String text;
Scanner scan = new Scanner(System.in);
System.out.print("Enter a string of characters: ");
text = scan.nextLine();
for (int z = 0; z < text.length(); z++) {
char c = text.charAt(z);
if (c=='a')
{
a++;
}
else if( c=='e')
{
e++;
}
else if(c=='i')
{
i++;
}
else if(c=='o')
{
o++;
}
else if (c=='u')
{
u++;
}
else
other++;
}
System.out.println("Number of vowel in the string: ");
System.out.println("a: " + a);
System.out.println("e: " + e);
System.out.println("i: " + i);
System.out.println("o: " + o);
System.out.println("u: " + u);
System.out.println("Number of non-vowel characters: " + other);
}
}
The code runs perfectly, but how do you add a do while loop to repeat this process?
TL;DR: How do you add a do while loop to repeat this process?
1
u/NatKurien Feb 21 '19
I think you need to be a little more specific with regard to your requirement. What is the condition that you are looking to loop through?