Can you have more than one user input prompt occur when running program? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Can you have more than one user input prompt occur when running program?

I understand I can import Scanner to have the user input prompt appear upon clicking the "Run" button. Is it possible to write code that will execute a print statement that asks for a type of input, prompt the user, print the answer and a follow up question for a different type of input, and then prompt the user again? For example: Click Run Print "What is your name?" User input box appears on screen and user inputs their name Print "My name is (name)." "What is your age?" User input box appears on screen AGAIN and user inputs their age Print "I am (age) years old." And so on. For clarification, I am a novice and have only completed the second module of the Java course. I'm not asking for the syntax of this situation, merely if it can be done using the compiler provided with SoloLearn.

11th Feb 2020, 7:41 PM
Thatsa Good Pep
Thatsa Good Pep - avatar
4 Réponses
+ 3
No you cannot do this in SL. All inputs must be entered before. If there are multiple then input on separate lines.
11th Feb 2020, 7:48 PM
Mihai Apostol
Mihai Apostol - avatar
+ 3
BroFar Mihai Apostol Thanks for the response. It's unfortunate that's how it is, but I'll just have to work around it for now.
11th Feb 2020, 11:13 PM
Thatsa Good Pep
Thatsa Good Pep - avatar
+ 2
Unfortunately no not on SoloLearn but you can address the inputs in the programming comments prior to someone executing the code...
11th Feb 2020, 8:10 PM
BroFar
BroFar - avatar
+ 2
Not on code playground for non web codes.
11th Feb 2020, 11:22 PM
Sonic
Sonic - avatar