0

How to input several lines

I wrote a code with 2 inputs, one is the name of a person and the other one is the surname. When running, at the beginnin program says that the code has several inputs, and they must be separated by a line. Inputs are strigs and I tried with: Joe Johnson It does not work. How can it be done? https://code.sololearn.com/cD4tUAk5iIun/?ref=app

14th Dec 2017, 11:41 AM
Jose
Jose - avatar
5 ответов
+ 4
After you've entered the first name, press enter on keyboard and enter surname on second line (same input box). This should work, but I got an error in your program. I commented out line 9 and changed line 13 to 'surname = n.nextLine();' You don't need line 9. You've already created a 'Scanner' in line 8.
14th Dec 2017, 12:22 PM
Duncan
Duncan - avatar
+ 3
No problem :)
14th Dec 2017, 12:36 PM
Duncan
Duncan - avatar
+ 1
thanks. you are righr with Scanner only one is necessary. anyway the code works in the PC. I will amend it to make it work here. thanks again
14th Dec 2017, 12:27 PM
Jose
Jose - avatar
0
the code works perfetcly in the PC with Netbeans.
14th Dec 2017, 11:43 AM
Jose
Jose - avatar
0
probably this app only supports one Scanner per code, and it can be used repeatedly splitting the inputs per line. thanks again!
14th Dec 2017, 12:36 PM
Jose
Jose - avatar