Results 1 to 2 of 2
- 10-18-2011, 03:04 AM #1Member
- Join Date
- Oct 2011
- Rep Power
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?
- 10-18-2011, 03:07 AM #2
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.
- By ouou in forum Advanced JavaReplies: 3Last Post: 06-11-2011, 06:51 AM
- By jhuwalker in forum New To JavaReplies: 2Last Post: 01-31-2011, 11:29 PM
- By movsesinator in forum New To JavaReplies: 4Last Post: 04-06-2010, 02:37 AM
- By MNoone in forum Jobs OfferedReplies: 1Last Post: 08-09-2008, 01:10 PM
- By Camden in forum New To JavaReplies: 1Last Post: 12-16-2007, 10:37 PM