Java a platform independent programming language.In this program you can rotate the number using Java.
EXAMPLE :
Original number:54321
Rotated Number :15432
PROGRAM :
import java.util.Scanner;
/**
* @author Arun
*/
public class rotatetest {
public static void main(String args[])
{
Scanner scn = new Scanner(System.in);
System.out.println("Enter the Number to rotate");
int number = scn.nextInt();
int length = (int)(Math.log10(number)+1);
int rotate = number%10;
rotate = rotate * (int) Math.pow(10, length-1);
number = number/10;
rotate = rotate + number;
System.out.println("Rotated numb is "+rotate);
}
}
EXAMPLE :
Original number:54321
Rotated Number :15432
PROGRAM :
import java.util.Scanner;
/**
* @author Arun
*/
public class rotatetest {
public static void main(String args[])
{
Scanner scn = new Scanner(System.in);
System.out.println("Enter the Number to rotate");
int number = scn.nextInt();
int length = (int)(Math.log10(number)+1);
int rotate = number%10;
rotate = rotate * (int) Math.pow(10, length-1);
number = number/10;
rotate = rotate + number;
System.out.println("Rotated numb is "+rotate);
}
}
No comments:
Post a Comment