Task: you need to enter purely from the keyboard and in it swap the last two digits.
100 <n <999 n enter from the keyboard after the change, we get x.
I believe that the solutions are a million. I would like to read the input through the scanner, limit the input from 101 to 998 and if the number is not in the range, then I would have to re-enter the number and as a result swap 2 and 3 digits: X is equal ... I figured out the scanner, but I can’t find the desired method to limit the input, in case of an error, return to the repeated input and in the input number, swap the digits. I don't need ready code, just push in the right direction.
import java.util.Scanner; // импорт сканера class Task { public static void main(String args[]){ System.out.print("Введите число: "); Scanner scan = new Scanner(System.in); int number = scan.nextInt(); System.out.println ("Вы ввели число " + number); } } java
x > 100 and x < 999and in the input number, swap the digitsy = 100 * (x \ 100) + 10 * (x % 10) + ((x % 100) \ 10). - Akina