User input for arrays | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

User input for arrays

I am doing a programming challenge and i am using an array to let users input factors for a deficient number. However I dont fully understand the concept so whenever I input the factors, they dont print. Can someone explain? My program https://code.sololearn.com/cTzjp7D6Ryvm/?ref=app https://code.sololearn.com/cTzjp7D6Ryvm/?ref=app https://code.sololearn.com/cTzjp7D6Ryvm/?ref=app

21st Jul 2018, 4:15 AM
C0D3X
C0D3X - avatar
1 Answer
+ 2
Use userInput.nextInt() instead of s.nextInt(). Also, in loop condition, write i < facts.length. Fixed code: https://code.sololearn.com/csHH1PKFdC4o/?ref=app
21st Jul 2018, 4:30 AM
Shamima Yasmin
Shamima Yasmin - avatar