Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Main.main(Main.java:9)
In print reverse
still showing same error
send me screenshot of custom input . and also send me your code
Copy the code and send it
import java.util.*;
public class Main {
public static void main(String args[]) {
{
int a, m = 0, sum = 0;
Scanner s = new Scanner(System.in);
int n = s.nextInt();
do
{
a = n % 10;
m = m * 10 + a;
sum = sum + a;
n = n / 10;
}
while( n > 0);
System.out.println(m);
System.out.println(sum);
}
}
}
//System.out.println(sum); remove this line and submit it
import java.util.*;
public class Main {
public static void main(String args[]) {
{
int a, m = 0, sum = 0;
Scanner s = new Scanner(System.in);
int n = s.nextInt();
do
{
a = n % 10;
m = m * 10 + a;
sum = sum + a;
n = n / 10;
}
while( n > 0);
System.out.println(m);
//System.out.println(sum);
}
}
}
again showing same error only
code is fine. you can call me . I gave phone number on chat
number didnt get on chat
@Monu-Singh-480654572341490 @karthik1989photos Can you please share here also what was the issue, I tried to solve it too and faced the same error.
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
long n = scanner.nextLong();
long ans = 0;
while(n != 0){
long rem = n%10;
ans = ans*10 +rem;
n = n/10;
}
System.out.println(ans);
}
}
Hey Surbhi
Code is working fine.
Yeah, it does work fine, when I submitted the code it passed all the test cases, but when I was compiling and testing the same code, it showed me this error. I think there is some issue with the code editor, i faced the same issue with other questions also.
Thank you for your reply!