Results 1 to 4 of 4
  1. #1
    altosoneca is offline Member
    Join Date
    Apr 2017
    Posts
    2
    Rep Power
    0

    Default loop program until "#'' is written.

    I need to write an algoritm to see if a character is either a number,letter or symbol . And it needs to loop until ''#'' is written , but the problem is that "#" is an illegal character.

    Java Code:
    char carac;
        Scanner entrada= new Scanner(System.in);
     
       
        
            System.out.print("Digite um caractere: ");
            carac= entrada.next().charAt(0);
            
            while (carac!=#)
    The part to identify if it is a number, letter or symbol i can do it but no the loop with "#"

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: loop program until "#'' is written.

    "#" is an illegal character.
    Yes a # floating around in the code is not legal. It could be in a String by wrapping it in "s ("X") or it could be a char by wrapping it in 's ('@')
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    altosoneca is offline Member
    Join Date
    Apr 2017
    Posts
    2
    Rep Power
    0

    Default Re: loop program until "#'' is written.

    oooh it worked , thank you totally forgot about the flying comma

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: loop program until "#'' is written.

    Quote Originally Posted by altosoneca View Post
    ... the flying comma
    It's called a single quote.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 0
    Last Post: 09-19-2013, 01:04 PM
  2. Replies: 1
    Last Post: 02-01-2012, 08:37 PM
  3. Written Java Program in Netbeans won't compile..
    By ptrasd12 in forum New To Java
    Replies: 5
    Last Post: 12-01-2011, 01:43 PM
  4. Change program written with inheritance to composition
    By subiedude101 in forum New To Java
    Replies: 1
    Last Post: 03-21-2011, 02:14 AM
  5. An "if" statement inside a "for" loop?
    By soccermiles in forum New To Java
    Replies: 18
    Last Post: 04-20-2010, 03:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •