Hi! I'm using Eclipse as an IDE, I need to code a program where users enter a string and it computes the count for each vowel, and how many words are in the string. Users can do as many strings as they want until they hit cancel. This is what I have so far:
-
import javax.swing.*;
-
public class Program
-
{ //Open Class
-
public static void main(String[] args)
-
{ //Open Main
-
String input, output; //Holds input and output.
-
int aCount = 0, eCount = 0, iCount = 0, oCount = 0, uCount = 0, numLines = 0; //Holds values for entries of respective vowels. All initialized to 0.
-
char v = 0; //v standing for vowel
-
-
String text = null;
-
do
-
{
-
input = JOptionPane.showInputDialog("Input a line to analyze or Cancel to quit: ");
-
input = input.toLowerCase();
-
input.length();
-
numLines = numLines + 1;
-
for (int wCount = 0; wCount < text.length(); wCount++)
-
v = text.charAt(wCount);
-
switch (v)
-
{//Open switch statement. Braces are not used because there is only 1 corresponding statement per case.
-
case 'a':
-
aCount = aCount + 1;
-
break;
-
case 'e':
-
eCount = eCount + 1;
-
break;
-
case 'i':
-
iCount = iCount + 1;
-
break;
-
case 'o':
-
oCount = oCount + 1;
-
break;
-
case 'u':
-
uCount = uCount + 1;
-
break;
-
-
}//Close switch statement
-
JOptionPane.showMessageDialog(null, "A-Count: " + aCount + "\n" + "E-Count: " + eCount + "\n"
-
+ "O-Count" + oCount + "\n" + "U-Count" + uCount + "\n" + "Word Count" + v + "Line Analisys - name here", text, JOptionPane.PLAIN_MESSAGE);
-
}//Close do while
-
while (input != null);
-
-
-
}//Close Main
-
}//Close Class
-
I have no idea where i'm going wrong, or if i'm even headed in the right direction =\