Check the syntax for the while loop. Also, look at your code your using
the "I" variable in your while look but it's never set to 0 when you
start your while loop. 

 

while (int i = 0; some check ; i++ ){

            Your code for checking

}

 

 

Cheers

 

From: Antara Pal [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 28, 2008 1:03 PM
To: Philpott, Patrick
Cc: [email protected]
Subject: Re: [java programming] HW-Lab1034

 

Hi here is the code:

 

import javax.swing.JOptionPane;

public class OwnWhile {
    public OwnWhile() {
    }
    public static void main(String[] args) {
        
        String [] names
={"Beah","Bianca","Lance","Belle","Nico","Yza","Gem","Ethan"};
        String searchName = JOptionPane.showInputDialog("Enter either
\"Yza\" or \"noname\"!"); 
        boolean foundName = false;
        int i = 0;
                
        do{
            if(names [i].equals(searchName)){
                foundName = true;
                break;
            }
            i++;
          } 
        while((foundName == false) && (i < names.length));
            
        if(foundName)        
                               
            JOptionPane.showMessageDialog(null, searchName + " is
found!");
                
        else
            JOptionPane.showMessageDialog(null, searchName + " is not
found!");
     }
    
}

 

Thanks

 

 


 

On Thu, Aug 28, 2008 at 12:58 PM, Philpott, Patrick
<[EMAIL PROTECTED]> wrote:

Code please. 

 

 

Cheers

From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Antara
Pal
Sent: Thursday, August 28, 2008 11:29 AM
To: [email protected]
Subject: [java programming] HW-Lab1034

 

Hi Everybody,

I have a question related to MyOwnWhileProject of HW 1034.

Is it fine if I use do-while instead of only while loop.

I tried writing the code with While only, but then I got some errors. 

If anyone had done the coding with While loop only, please let me know
the codes.

 

Thanks

Regards

Antara



This communication is intended for the named recipient(s) only, and may
contain confidential information subject to legal protection and not
intended for public disclosure unless specifically permitted by the
sender. If you are not the named recipient, you hereby are notified that
you may not disclose, copy, distribute or take any action in reliance on
the contents of this communication.

 


This communication is intended for the named recipient(s) only, and may contain 
confidential information subject to legal protection and not intended for 
public disclosure unless specifically permitted by the sender. If you are not 
the named recipient, you hereby are notified that you may not disclose, copy, 
distribute or take any action in reliance on the contents of this communication.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to