Multiple Inputs | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Multiple Inputs

Java: I am making a simple program that has the user try and guess a secret number. What program would I write if I wanted to allow the user to keep guessing if they get it wrong (until they get it right). Thanks!

22nd Feb 2018, 2:52 AM
Maddie
Maddie  - avatar
4 Answers
+ 2
You would use a while loop to do this. Format (I don't know what language it is in): While guess != secretNumber input guess
22nd Feb 2018, 3:14 AM
Colin
Colin - avatar
+ 1
using scanner to get input you would do, Scanner input = new Scanner (System.in); String guess; while(guess!=secretNumber){ guess = input.next (); }
22nd Feb 2018, 3:31 AM
Joseph David Zamora Murillo
Joseph David Zamora Murillo - avatar
0
im what programming language is it?
22nd Feb 2018, 3:10 AM
Joseph David Zamora Murillo
Joseph David Zamora Murillo - avatar
0
It is in java, sorry!
22nd Feb 2018, 3:28 AM
Maddie
Maddie  - avatar