I am having difficulty converting this project from a "for" loop to a
"while" loop.  Everything that I input is "found".  I am not sure where the
problem is.  The homework specifies to use a while loop.  Does that mean
that I could also use a do-while or is that not allowed/necessary?  Here is
what I have.  Thanks in advance!




import javax.swing.JOptionPane;

public class MyOwnWhileProject {

    /** Creates a new instance of ForLoop */
    public MyOwnWhileProject() {
    }

    /**
     * @param args the command line arguments
     */
    @SuppressWarnings("empty-statement")
    public static void main(String[] args) {
        // Declare and initialize String array variable called names.
        String names
[]={"Beah","Bianca","Lance","Belle","Nico","Yza","Gem","Ethan"};

        // This is the search string we are going to use to search the
array.
        String searchName = JOptionPane.showInputDialog("Enter either
\"Yza\" or \"noname\"!");

        // Declare and initialize boolean primitive type variable calld
foundName.
        boolean foundName =false;



        int i =0;
        while (i<names.length){
                i++;
                foundName =true;
                break;


        }

        // Display the result
        if (foundName)
            JOptionPane.showMessageDialog(null, searchName + " is found!");
        else
            JOptionPane.showMessageDialog(null, searchName + " is not
found!");

    }

}

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

To unsubscribe from this group, send email to 
javaprogrammingwithpassion+unsubscribegooglegroups.com or reply to this email 
with the words "REMOVE ME" as the subject.

Reply via email to