Print Reverse test cases not passing

import java.util.*;

import java.util.Scanner.*;

public class Main {

public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int rem = 0;
	int rev = 0;
	int sum = 0;
	if(n>=0)
	{
		while(n>0)
			{
			rem = n%10;
			sum= sum+ rem;
			rev= rev*10 + rem;
			n =  n/10;
			}
		System.out.println("Number in reverse = "+ rev);
		System.out.println("Sum of Numbers = " + sum);
	}
	else if(n<0)
	{
		while(n<0)
			{
			rem = n%10;
			sum= sum+ rem;
			rev= rev*10 + rem;
			n =  n/10;
			}
		System.out.println("Number in reverse = "+ rev);
		System.out.println("Sum of Numbers = " + sum);
	}
}

}

I have checked for both negative as well as positive number

Hi @Inam

Please check the input and output format once. Your output should exactly match the given output format.

For input:
12345678

Expected output is:
87654321

But your code’s output is:
Number in reverse = 87654321
Sum of Numbers = 36

So, please avoid printing extra things and just print the required output only.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Still the test cases are not passing

it defined constraints 0 <= N <= 1000000000 , but when compiling it shows error that none of your test cases passed maybe because you have not included negative numbers.

Also, the question stated that i just don’t have to print the reverse, but also calculate it’s sum

Hi @Inam

Can you please copy your updated code at cb.lk/ide, save it and share the url. So, that I can check the exact issue in your updated code.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.