Results 1 to 2 of 2
  1. #1
    hreodbeohrt is offline Member
    Join Date
    Oct 2011
    Rep Power

    Default if wrong input, you get a new chance


    Just started java and was trying to create something.

    The user is supposed to type in 6 numbers within a range from 1 - 64 . If the user types an invalid number, he will get a new shot. But all 64 numbers have to be correct, as they are going in to an array.

    How would I implement that input system without making it to messy?

    Thanks !

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

    Default Re: if wrong input, you get a new chance

    You have to make two checks: number is within the correct range and number is not already selected. Simple if statement handles the first problem. For the second use a loop to check all numbers selected so far against the new selected number. Place code to handle both (use of methods would be good) inside a loop that keeps going if either check fails.

    Maybe I misinterpreted your post and the second (unique numbers) issue is not what you need.

Similar Threads

  1. Replies: 3
    Last Post: 06-11-2011, 05:51 AM
  2. New To Java - Input Number Won't Prompt, Wrong Result
    By jhuwalker in forum New To Java
    Replies: 2
    Last Post: 01-31-2011, 10:29 PM
  3. Handling Errors IE: Wrong User Input
    By movsesinator in forum New To Java
    Replies: 4
    Last Post: 04-06-2010, 01:37 AM
  4. Replies: 1
    Last Post: 08-09-2008, 12:10 PM
  5. handle wrong input int/null
    By Camden in forum New To Java
    Replies: 1
    Last Post: 12-16-2007, 09:37 PM

Posting Permissions

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