+ 1

Why this doesn't work?

this has to output as many lines of code as the number you input https://code.sololearn.com/cDFBU7bjolvh/?ref=app https://code.sololearn.com/cDFBU7bjolvh/?ref=app

25th Sep 2018, 12:05 PM
SummerWizard
SummerWizard - avatar
6 Antworten
+ 2
You need to store the integer of the scanner in a variable before your while : else each loop of your while will try to read the next value of your scanner "value" which doesn't exist if the user just inputs one integer (which is your intended use I guess). Try to replace l.9 of your code with that piece : int num=value.nextInt(); while(x < num){ Should work. Do you understand the problem ? Edit : be careful also, your main method e.g. the line 5 public static void Main(String[] args) { should have "main" not capitalized.
25th Sep 2018, 12:37 PM
dhm
+ 1
Ignore my first awnser, it shouldn't be capitalized I haven't looked at java since a long time
25th Sep 2018, 12:46 PM
CodeMStr
CodeMStr - avatar
+ 1
dhm thanks, that worked
25th Sep 2018, 1:26 PM
SummerWizard
SummerWizard - avatar
0
main should be capitalized Edit: ignore
25th Sep 2018, 12:07 PM
CodeMStr
CodeMStr - avatar
0
Niek Aukes still doesn't work
25th Sep 2018, 12:20 PM
SummerWizard
SummerWizard - avatar
0
Niek Aukes any ideas how to fix?
25th Sep 2018, 12:25 PM
SummerWizard
SummerWizard - avatar