Write a program in JAVA to input a number and determine the number of digits. Now form an integer that has the number of digits and most significant digit at ones’ place. Display the number Sample Input : 2136 Sample Output : 46
Answers
Answered by
4
import java.util.Scanner;
class OnesPlace {
public static void main(String[] args) {
try {
System.out.println("Enter a number: ");
Scanner getInput = new Scanner(System.in);
int Number = getInput.nextInt();
String Str_Number = Integer.toString(Number);
System.out.print(Integer.toString(Str_Number.length()) + Str_Number.charAt(Str_Number.length() - 1));
getInput.close();
} catch (Exception exception) {
System.out.println(exception.toString());
}
}
}
Similar questions