0

Java, any idea why this code doesn't work?!

I coded it on Netbeans, but when copied into SL, it doesn't run properly. As far as i can see, the Scanner doesn't work properly. Well, my first try to code smth in Java. Thanks for your advice.... https://code.sololearn.com/cr9rxfcdwSgQ/#java

4th Nov 2017, 11:58 AM
wenz
wenz - avatar
6 Answers
+ 2
"is it possible to make a break in the text output instead of writing two separate lines?!" - Sure just use "\n" in the string Your program doesnt work because you are asking for alot of user input, everytime your while loop repeats it expects another input. In a normal java application this would work as the program would sinply continue to ask for another input. In Code playground you need to enter ALL inputs before executing
4th Nov 2017, 12:53 PM
Jeremy
Jeremy - avatar
+ 6
you only need to create one instance of scanner and use " \n " to create a new line.
4th Nov 2017, 1:05 PM
D_Stark
D_Stark - avatar
+ 1
one suggestion no need to define the scanner statement again and again.
4th Nov 2017, 12:36 PM
Nanda Balakrishnan
+ 1
@wenz multiple inputs in code playground are achieved by writing each input in a new line but since you dont know how many inputs are needed thats not an option. Dummy inputs are the only way to go here (maybe an array with different values that are used randomly)
4th Nov 2017, 1:20 PM
Jeremy
Jeremy - avatar
0
@Jeremy Aaaahhh.... I think I got it. ... basically we would need to 'simulate' the user input by dummy variables/values in order to make it run in SL. ... but it's not possible in SL to let a code run like this (many user inputs)?! Right? thx... I'm in the very very beginning...
4th Nov 2017, 1:05 PM
wenz
wenz - avatar
0
@Jeremy perfect! got it :)
4th Nov 2017, 1:22 PM
wenz
wenz - avatar