i'm writing a Java program that ask the user to input words using JOptionPane.showInputDialog()
Then look at each letter in the word and add up the points for each letter.
Vowels (a,e,i,o and u) are valued at zero.The letters "x" and "q' are valued at 5.All other are 1.Anything not a letter should be ignored.
Then using a JOptionPane.showMessageDialog(), display the word and the score.
Repeat this process until the user types the word "Stop".

Here is what i got so far,it's seem that only the loop are working.please help me

import javax.swing.JOptionPane;

public class Project0 {
public static String[] Vowels = { "a", "e", "i", "o", "u" };
public static String[] Letters = { "x", "q" };
public static String inputWord;

public static void main(String[] args) {
int Cntr = 0;
while (true) {
inputWord = JOptionPane.showInputDialog("Enter a word: ");
if (inputWord.equals("STOP") || inputWord.equals("stop")) {
System.exit(0);
} else if (VowelsCounter(inputWord, Vowels)) {
Cntr += 0;
} else if (LettersCounter(inputWord, Letters)) {
Cntr += 5;
} else if ((!(inputWord.equals(Vowels))))
		{
Cntr += 1;
} else {
JOptionPane.showMessageDialog(null, "The word is: " + inputWord+ "Score" + Cntr++);
}
}// true
}// main

public static boolean VowelsCounter(String inputWord, String[] Vowels) {
int Cntr = 0;
for (int i = 0; i <= Vowels.length; i++) {
if (inputWord.equals(Vowels)) {
Cntr += 0;
return true;
}
}
return false;
}// VowelsCounter

public static boolean LettersCounter(String inputWord, String[] Letters) {

int Cntr = 0;
for (int i = 0; i <= Letters.length; i++) {
if (inputWord.equals(Letters)) {
Cntr += 5;
return true;
}
}
return false;
}// LettersCounter
}

Maybe change the Counter methods to return the count rather than just a boolean. Then in your main loop you can just add up those counts. VowelsCounter seems unneccessary, since vowels don't score anything.
You code will be easier to read & debug if you indent it properly. Mostcode editors and IDEs will do this for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.