0
I need some help with scanners. Anyone?
2 ответов
+ 1
what do you mean? like how to let the user interact with your program if so th code is:
playerAnswer = scan.nextLine ();
im sure you know about if, else, and else if statements so just do that for your users options. and if your doing a console game and want to make sure the user can only type one of the options, put that code and the other statements within a while loop thats set to true. the reason why you should do this is because if for example you have two options apple and pear and the player says orange. if you put a message in there some where saying "sorry, answer not recognized" it will say that message and repeat the question. hope that helped :)
+ 1
scanner is used to get input in java by user......it is one of many input taking way in java....gor example if u want to add numbers taken from user then use scanner to take input from user i.e integer