Want to write a student achievement input but thought about the possible input error input string to determine if a string is suggested to let he again input is under the Numbers you went to consult bigwigs use input method to design train of thought
CodePudding user response:
For example
Scanner sc=new Scanner (System. In); String s=""; While (true) { System. The out. Println (" please enter the grade: "); S=sc. NextLine (); If (s.m atches (" ^ \ \ d + ([.] \ \ d +)? Break $"));//legal data is cycle } Double d=double. The valueOf (s);//convert the input to a double //do your process