AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



corejava-programming: Program to find reverse number in Arabic numerals

Reversed number is a number written in arabic numerals but the order of digits is reversed. The first digit becomes last and vice versa. Note that all the leading zeros are omitted. That means if the number ends with a zero, the zero is lost by reversing (e.g. 1200 gives 21). Also note that the reversed number never has any trailing zeros.

corejava x 333
programming x 150
Posted On : 2017-11-27 10:47:21.0
profile Dinesh - anyforum.in Dinesh
300
up-rate
3
down-rate

Answers


import java.util.Scanner;

public class ArabianReverseNumerals {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println(getReverseNumber(input.nextInt()));
}
public static int getReverseNumber(Integer number){
int reverseNumber=0;
char[] digits=number.toString().toCharArray();
int length = digits.length;
char[] reverseDigits = new char[length];
for(int i=length;i>=1;i--){
reverseDigits[length-i]=digits[i-1];
}
reverseNumber=Integer.valueOf(String.valueOf(reverseDigits));
return reverseNumber;
}
}

Posted On : 2017-11-28 23:37:10
Satisfied : 1 Yes  0 No
profile Garima Gupta - anyforum.in Garima Gupta
596128122138
Reply This Thread
up-rate
0
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in