Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Help me in java coding

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help me in java coding

    I had just started learning java and i totally have no experience in programming before.

    So my lecturer asked the whole class to create a coding to detect identifier problems.

    The question is:

    Create a coding by asking user to input random letters and etc.

    If the there is no identifier error the output will print out " Successful data input" and vice versa "The data contains identifier error".

    My lecturer said its a simple coding but i still can't figure it out. So somebody please help me and do make it simple because i had only learned till buffreader.

    By the way im using texpad.

    Thanks in advance and hope the problem will settle asap.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,155
    Thanks
    65
    Thanked 2,722 Times in 2,672 Posts

    Default Re: Help me in java coding

    Break the program into simple steps and do them one at a time.
    First step:
    ask the user a question and get his response.
    Then print out his response.

    Look at the Scanner class for ways to read the input.

  3. #3
    Junior Member
    Join Date
    Aug 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me in java coding

    I only want to know how to detect the errors of the identifier so that i can create the coding and the produce the "The data contains identifier error".

    I only manage to get to the successful data input. But when i input random letters that contains # it still comes out as successful. So i want to know how to detect the identifier error in the coding.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,155
    Thanks
    65
    Thanked 2,722 Times in 2,672 Posts

    Default Re: Help me in java coding

    I only want to know how to detect the errors of the identifier
    To do that you need to define the "syntax" for a valid identifier.
    Do you have that? What is a valid identifier?

  5. #5
    Junior Member
    Join Date
    Aug 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me in java coding

    example if i input : #alslsl

    It would print invalid as it cannot start with the # symbol, % symbol and numbers.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,155
    Thanks
    65
    Thanked 2,722 Times in 2,672 Posts

    Default Re: Help me in java coding

    To write the code, you need a definition of what the code is to do.
    Can you define what a valid identifier is?
    Or what an invalid identifier is? Examples are not good enough, unless you can list ALL of the millions of bad identifiers.

    Something like this: The first character must be an uppercase letter from A-K, followed by 2 or more numeric digits in the range 4-7 followed by 1 lower case letter in the range: k-m. For example: H445m is valid. H4k is not valid.

Similar Threads

  1. Java Applet Coding Help?
    By Drag01 in forum Java Applets
    Replies: 1
    Last Post: April 26th, 2012, 07:03 AM
  2. Java coding help
    By Javalover1 in forum The Cafe
    Replies: 0
    Last Post: April 12th, 2010, 08:11 PM
  3. Replies: 0
    Last Post: December 23rd, 2009, 01:54 PM
  4. Sudoku coding help...please
    By sketch_flygirl in forum Algorithms & Recursion
    Replies: 2
    Last Post: December 5th, 2009, 10:07 PM
  5. 15, Loves ICT, learning Java coding.
    By Sergant Mitch in forum Member Introductions
    Replies: 1
    Last Post: September 20th, 2008, 09:40 AM