+ 3

Can you help me to change it in java codešŸ™‚

Sum reverse https://code.sololearn.com/cxAKCUs2pVq0/?ref=app

14th Mar 2022, 2:15 AM
Ecyojer
Ecyojer - avatar
5 Answers
+ 3
Try wrapping your code in the Program class for it to run on Sololearn... public class Program { public static void main(String[] args) { } }
14th Mar 2022, 2:51 AM
Paul K Sadler
Paul K Sadler - avatar
+ 3
import java.util.Scanner; public class Ecyojer { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int num1=sc.nextInt(); int num2=sc.nextInt(); int rnum1 = reverseNum(num1); int rnum2 = reverseNum(num2); int sum = rnum1+rnum2; System.out.println(sum); } public static int reverseNum(int n) { int reverse = 0, rem; while (n != 0) { rem = n % 10; reverse = reverse * 10 + rem; n /= 10; } return reverse; } }
14th Mar 2022, 3:01 AM
Tarik Khalil
Tarik Khalil - avatar
14th Mar 2022, 3:01 AM
Tarik Khalil
Tarik Khalil - avatar
+ 2
Paul K Sadler The code needs to be changed syntax completely from C++ to JAVA
14th Mar 2022, 10:55 PM
Tarik Khalil
Tarik Khalil - avatar
+ 2
Yes, that's correct. I was giving a starting point for the conversion. But, stopped short of doing it for her since the effort of doing it, is the best way to learn.
14th Mar 2022, 11:06 PM
Paul K Sadler
Paul K Sadler - avatar