Write a program to display numeric value in reverse order.
Ex: I have given a number like 7584, It should display in
reverse order like 4857.

Answer Posted / selvi

import java.util.Scanner;

public class IntReverseOrder
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
StringBuffer sb = new StringBuffer();
int remainder;

while(num>0)
{
remainder = num%10;
sb = sb.append(remainder);
num = num/10;

}
System.out.println("Reverse Order = "+sb);
}

}

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the components of j2ee?

663


Give some advantages of orm (object-relational mapping)?

778


Differentiate between .ear, .jar and .war files.

828


for example we are login into the irctc server from there it will go to the selected bank and deduct amount and come back to the irctc. so if we are developing this in java means will it be run on the same session. but as per my knowledge bank is separate and irctc is separate URL's so it will use two different sessions then how it is maintaining same session through out application and even it uses the payment gateway? how it is working can any one help me on that??

4073


What is considered as a web component?

796


what is meant by proxy server

4512


How is java development environment setup?

676


What is jaap?

750


How java is reliable?

660


What is element?

738


What is j2ee architecture?

673


What is the use of method save()?

723


What is j2ee api?

745


What is java mobile?

692


What is ejb container provider?

645