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 is B2B?

757


What should a junior java developer know?

649


What is j2ee product?

679


What is multi tier architecture in j2ee?

637


Is tomcat a java ee?

662


What is a thin client?

738


What is a component in java?

648


What are the components of awt in java?

690


What is a java ee container?

653


What do you understand by connector?

679


What is the latest technology used in java?

721


What is server in j2ee?

646


Is java a tool?

704


What do you understand by actionform?

652


What is java servlet container?

686