+ 2

Please anyone help me, Tell me how can i input 5 integers in a code?? As i do " 5,12,32,45,11 " , its showing an error message!!

https://code.sololearn.com/cAMy2qdsFTyO/?ref=app

25th Aug 2020, 7:21 AM
I M J
I M J - avatar
23 Réponses
+ 6
Modified your code MJ Tech Sample input: 1 2 3 4 5 https://code.sololearn.com/czr378qDmt0C/?ref=app
25th Aug 2020, 7:39 AM
Namit Jain
Namit Jain - avatar
+ 6
MJ Tech I have sent the solution, pls acknowledge
25th Aug 2020, 7:41 AM
Namit Jain
Namit Jain - avatar
+ 6
MJ Tech your basic concepts are not clear https://www.sololearn.com/learn/Java/2147/
25th Aug 2020, 7:44 AM
Namit Jain
Namit Jain - avatar
+ 4
MJ Tech you removed the already existing things in the program. Every new java project in SoloLearn has a class and the main method already defined
25th Aug 2020, 7:47 AM
Namit Jain
Namit Jain - avatar
+ 3
Why is your array size only 1 when you want to input 5 values? How to input array in java MJ Tech check this code https://code.sololearn.com/cWppfsdA6QRx/?ref=app
25th Aug 2020, 7:22 AM
minirkk
minirkk - avatar
+ 2
MJ Tech for (int i=0 ; i<1; i++) i<1 this makes the for loop to execute only once.
25th Aug 2020, 7:24 AM
minirkk
minirkk - avatar
+ 1
MJ Tech Input in this format: 1 2 3 4 5 Different Inputs must be seperated by new line EDIT: i < 4 (Wrong) i < 5(Right) ANOTHER EDIT: i < 4 will ask for input 4 times i < 5 will ask for input 5 times
25th Aug 2020, 7:28 AM
Saphal Poudyal
Saphal Poudyal - avatar
+ 1
MJ Tech You forgot a { after main() like so public static void main (String[] args){
25th Aug 2020, 7:34 AM
minirkk
minirkk - avatar
+ 1
MJ Tech It would run if it was <= 4 but since it is < 4 it will only run until counter is 3. Thus , the input asked is 4 times
25th Aug 2020, 7:38 AM
Saphal Poudyal
Saphal Poudyal - avatar
+ 1
MJ Tech Ćheyat its always safe and good practice to use the length function instead of some raw value like 5 or 4. Like so. for (int i = 0; i < a.length; i++)
25th Aug 2020, 7:40 AM
minirkk
minirkk - avatar
+ 1
MJ Tech See Namit Jain 's code
25th Aug 2020, 7:42 AM
Saphal Poudyal
Saphal Poudyal - avatar
+ 1
Namit Jain rkk Ćheyat Thank you all... The program works ...
25th Aug 2020, 8:07 AM
I M J
I M J - avatar
+ 1
Hey your code is perfect the problem is in input type the input like this 1 2 3 4 5
26th Aug 2020, 8:50 AM
Born 2 Studio
Born 2 Studio - avatar
0
rkk oh thanx sir to remind...but.. I did it 5 just now...again it shows error
25th Aug 2020, 7:24 AM
I M J
I M J - avatar
0
rkk oh Thanx again...but it still gives error 'file not found...'
25th Aug 2020, 7:27 AM
I M J
I M J - avatar
0
Ćheyat oh thanx bro...let me do it now
25th Aug 2020, 7:29 AM
I M J
I M J - avatar
0
Ćheyat but see I initialized I by 0, so for 5 times it should run 0 to 4 !!
25th Aug 2020, 7:37 AM
I M J
I M J - avatar
0
Ćheyat I did; 1 2 3 4 5 But again it showed ; "error : file not found: /usercode/*.java Usage : javac <options> <source files> use --help for a list of possible options "
25th Aug 2020, 7:41 AM
I M J
I M J - avatar
0
Namit Jain ok thanks I understood... actually its first time I'm typing in this platform.....so I missed some elements
25th Aug 2020, 7:46 AM
I M J
I M J - avatar
0
Ćheyat yes I understood, sorry it should be i =0; i <5 ; i ++...
25th Aug 2020, 7:47 AM
I M J
I M J - avatar