+ 3

Program not working ...i dont know how to take input at compile time ... through scanner..xan any one find error.

import java.util.Scanner ; class MyClass { public static void main(String[ ] args) { Scanner in=new Scanner (System.in); int n=in.nextint (); for(int i=1;i<=n;i++){ if(n%i==0) { System.out.println(i); } else{ continue ; } } } }

23rd Mar 2018, 6:05 AM
Pooja chouhan
Pooja chouhan - avatar
3 odpowiedzi
+ 14
You wrote wrong method. Please change to nextInt() like this: int n=in.nextInt ();
23rd Mar 2018, 6:09 AM
Nithiwat
Nithiwat - avatar
+ 2
Tnx
24th Mar 2018, 4:53 AM
Pooja chouhan
Pooja chouhan - avatar
0
you can use sc.nextInt() inside the for loop to take multiple inputs
24th Mar 2018, 8:22 AM
Sagnik Majumder2
Sagnik Majumder2 - avatar