I have this simple project that I'm sure has come throught here before. I am take input from a user using JOptionPane, make sure it is >15 Chars, and count the uppercase.
Here is what I have so far. I am having trouble setting the first loop correctly.

import java.io.*;
        import javax.swing.JOptionPane;

public class WordCount { //using JOptionPane to take input from user and displaying it in dialog box.
  public static void main(String[] args)throws IOException {
    String userInput;
            userInput = JOptionPane.showInputDialog(" Please enter your 15 characters: ");
            JOptionPane.showMessageDialog(null, "You entered: " + userInput);
            int len = userInput.length();
            while(len < 15){
            JOptionPane.showInputDialog(" Please enter at least 15 characters ");
8 Years
Discussion Span
Last Post by MxDev

Your brackets are all over the place. You open them and you don't close them correctly. Start over and this whatever opens close it, and write code inside it.

At the while loop you don't update the len value inside it. You say that "Please enter at least 15 characters" have to be entered but then you don't anything about it. The loop will continue running and the len doesn't change.
Shouldn't you do something to change it?



I rewrote your code, but I haven't compile it so, this is your assignment to do. Here's the code.

public class WordCount{
    public static void main(Strings[] args){

        String userInput = "";

        while(userInput.length() < 15){

            userInput = JOptionPane.showInputDialog("Please enter your first 15 characters: ");     


        JOptionPane.showMessageDialog(null, "Thanks :)!!");

    }//end of the entry point

}//end of the class

I hope this benefits you. Happy coding :)


Edited by Nick Evan: Fixed formatting

Votes + Comments
Still no code tags and not giving a chance to the poster to learn
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.