话不多说,直接上代码
public static void NunOrChina2(Scanner scan) {
boolean flag = true;
while (flag){
String dou = scan.nextLine();
if (dou.equals("结束"))break;
//判断是否为数字
Pattern pattern = Pattern.compile("^[-\\+]?[.\\d]*$");
if(!pattern.matcher(dou).matches()) {System.out.println("请重新输入。。。");continue;}
// 大写数字数组
String[] num = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
// 数量单位数组,个位数为空
String[] unit = {"", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "兆", "拾", "佰", "仟", "万", "京"};
String d = dou.to