public class Test01 {
public static void main(String[] args) {
System.out.println("请你输入一个字符串:");
Scanner sc = new Scanner(System.in);
String str = sc.next();
// 中文的正则表达式
String chinese = "^[\u4e00-\u9fa5]{0,}$";
// 英文的正则表达式
String english ="^[A-Za-z]+$";
// 根据正则表达式,判断是否是数字
if(str.matches(chinese)||str.matches(english)){
System.out.println("不是数字");
}else {
int index = str.indexOf(".");
if (index>0) {
float num = Float.parseFloat(str);
System.out.println(num*5);
}else {
int num = Integer.parseInt(str);
System.out.println(num*10);
}
}
}
}
12-19
1190