I'm working on lottery game (user inputs 6 number, i will generate 8 unique winning numbers and 2 last numbers are supplementary). I need help with user input checking if input numbers are from 1 to 45 and input must be int, when input is not integer it throws an error.
This programming way is procedure way, how can i change it into object oriented way? I know that I must make methods in another java file and then link it back to this main. Can you suggest me how to do it?
I have tried try and catch, if and else (for input check) but i don't know how to check user input when it's in array. Thank you for help.
It check if user input into array is from 1 to 45.
What are some numbers for which that test will be true? What do you want to do with those numbers?
If test is true, user can continue in the program and get result from the program.
Okay, so you seem to understand that (check > 0 && check < 45) means that the value of check is between 0 and 45, although you seem confused about the endpoints, as you know that it doesn't include 0, but you seem to think it does include 45.
You also know that if the test evaluates to true (that is, the number is in the range 1..44) that you want the user to be able to continue on.
Now go back and look at your code:
Do you see how the code you wrote disagrees with what you said you understand and what you said you want to happen?
Good heavens! What have you done! Here, try to fix it with this tiny ad:
create, convert, edit or print DOC and DOCX in Java