如何输入像“23423”这样的数字并像“2 3 4 2 3”一样输出?以及如何使用户不能输入少于或多于 5 位的数字?(您的帮助将不胜感激。因为我正在学习 Java,所以我只需要你们的提示。期待学习新的东西。)
这是我到目前为止所拥有的:
Scanner input = new Scanner(System.in);
int value1, value2, value3, value4, value5;
System.out.print("Enter a number: ");
value1 = input.nextInt();
System.out.print("Enter a number: ");
value2 = input.nextInt();
System.out.print("Enter a number: ");
value3 = input.nextInt();
System.out.print("Enter a number: ");
value4 = input.nextInt();
System.out.print("Enter a number: ");
value5 = input.nextInt();
System.out.printf(" %d " + " %d " + " %d " + " %d " + " %d\n ", value1, value2, value3, value4, value5);