import java.util.Scanner;
public class MatchesMethodTest {
public static void main(String[] args) {
String s;
Scanner input = new Scanner(System.in);
System.out.print("Input one real number to one decimal place and one natural number(ex. 1.4 5): ");
s = input.next();
if (s.matches("\\f{1} \\d{1}$"))
System.out.print("You input correctly.");
else
System.out.print("You input incorrectly.");
}
}
사용자는 하나의 소수점 이하 하나의 자연수를 입력해야합니다. 이 프로그램은 사용자 입력이 올 바르고 잘못 입력되었는지 여부를 인쇄합니다. 그래서 1.4와 5를 입력 할 때, 프로그램이 "You input is"를 인쇄하기를 원하지만 "You can incorrectly"라고 출력합니다. 이 문제를 어떻게 해결할 수 있습니까?이 프로그램은 정확한 입력 값을 구별하는 것입니다.
캡쳐 화면을 캡쳐하고 출력 할 수 있습니까? – PaoloVictor
확실히 나는 Paolo 수 있습니다. – schizoid322