hey here is what i got.... i get an error after my while statement that i need a ; after my while but that dosent make any since, cause there shouldnt be any ideas???? suppose to be an easy loop statement if the string does not contain @ then keep prompting the user until there is an @ in the string.

* Week_seven_number_twenty_six application
 *
 * @author 
 * @version 1.00 2012/3/14
 */
import javax.swing.JOptionPane;
public class Week_seven_number_twenty_six 
{
    
    public static void main(String[] args) 
    {
    	
    	do
    	{
    		String INPUT = JOptionPane.showInputDialog(null,"Please input what ever you like as long as it contains the '@' symbol");
    	}
    	while(INPUT.contains("@"))
    	{

			System.out.println(""+INPUT);
    	}
    	
    }
}

make that a do while loop, it expected that the while loop is a part do loop

yes thats what i want to do but when i have it set up and add in ; i get the error cant find the symbol variable INPUT in the while statement...

/**
 * @(#)Week_seven_number_twenty_six.java
 *
 * Week_seven_number_twenty_six application
 *
 * @author 
 * @version 1.00 2012/3/14
 */
import javax.swing.JOptionPane;
public class Week_seven_number_twenty_six 
{
    
    public static void main(String[] args) 
    {
    	
    	do
    	{
    		String INPUT = JOptionPane.showInputDialog(null,"Please input what ever you like as long as it contains the '@' symbol");
    		System.out.println(""+INPUT);
    	
    	}while(INPUT.contains("@"));
    }
}

and it is right there as a string :?

don't initialize variables in a loop

ok got it thanks! although i think have this a bit backwards i need to get out of the loop when the string contains the @ symbol but when i enter the @ symbol it stays in loop. I know why its doing it but how would you got about reversing it the other way around?

/**
 * @(#)Week_seven_number_twenty_six.java
 *
 * Week_seven_number_twenty_six application
 *
 * @author 
 * @version 1.00 2012/3/14
 */
import javax.swing.JOptionPane;
public class Week_seven_number_twenty_six 
{
    
    public static void main(String[] args) 
    {
    	String INPUT;
    	do
    	{
    	    INPUT = JOptionPane.showInputDialog(null,"Please input what ever you like as long as it contains the '@' symbol");
    		
    	
    	}while(INPUT.contains("@"));
    	
    	System.out.println(""+INPUT);
    }
}

use the NOT(!) operator at the loop condition

wow brain fart moment thanks forgot about the ! its been a few months since i last coded thanks!!!

/**
 * @(#)Week_seven_number_twenty_six.java
 *
 * Week_seven_number_twenty_six application
 *
 * @author 
 * @version 1.00 2012/3/14
 */
import javax.swing.JOptionPane;
public class Week_seven_number_twenty_six 
{
    
    public static void main(String[] args) 
    {
    	String INPUT;
    	do
    	{
    	    INPUT = JOptionPane.showInputDialog(null,"Please input what ever you like as long as it contains the '@' symbol");
    		
    	
    	}while(!INPUT.contains("@"));
    	
    	System.out.println(""+INPUT);
    }
}
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.